Template Upload
This commit is contained in:
6
node_modules/reflect-metadata/spec/biblio.json
generated
vendored
Normal file
6
node_modules/reflect-metadata/spec/biblio.json
generated
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"http://people.mozilla.org/~jorendorff/es6-draft.html": {
|
||||
"abstract operations": {
|
||||
}
|
||||
}
|
||||
}
|
234
node_modules/reflect-metadata/spec/css/elements.css
generated
vendored
Normal file
234
node_modules/reflect-metadata/spec/css/elements.css
generated
vendored
Normal file
@ -0,0 +1,234 @@
|
||||
body {
|
||||
font-size: 18px;
|
||||
line-height: 1.5;
|
||||
font-family: Cambria, Palatino Linotype, Palatino, Liberation Serif, serif;
|
||||
margin: 0 20%;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
a:link {
|
||||
text-decoration: none;
|
||||
color: #3333bb;
|
||||
}
|
||||
|
||||
a:hover {
|
||||
text-decoration: underline;
|
||||
color: blue;
|
||||
}
|
||||
|
||||
a:visited {
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
code {
|
||||
font-weight: bold;
|
||||
font-family: Consolas, Monaco, monospace;
|
||||
white-space: pre;
|
||||
}
|
||||
|
||||
pre code {
|
||||
font-weight: inherit;
|
||||
}
|
||||
|
||||
pre code.hljs {
|
||||
background-color: #fff;
|
||||
}
|
||||
|
||||
ol.toc {
|
||||
list-style: none;
|
||||
padding-left: 0;
|
||||
}
|
||||
|
||||
ol.toc ol.toc {
|
||||
padding-left: 2ex;
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
emu-val {
|
||||
font-weight: bold;
|
||||
}
|
||||
emu-alg ol, emu-alg ol ol ol ol {
|
||||
list-style-type: decimal;
|
||||
}
|
||||
|
||||
emu-alg ol ol, emu-alg ol ol ol ol ol {
|
||||
list-style-type: lower-alpha;
|
||||
}
|
||||
|
||||
emu-alg ol ol ol, ol ol ol ol ol ol {
|
||||
list-style-type: lower-roman;
|
||||
}
|
||||
|
||||
emu-note {
|
||||
display: block;
|
||||
margin-left: 5em;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
emu-note span.note {
|
||||
text-transform: uppercase;
|
||||
margin-left: -5em;
|
||||
display: block;
|
||||
float: left;
|
||||
}
|
||||
|
||||
emu-production {
|
||||
display: block;
|
||||
margin-top: 1em;
|
||||
margin-bottom: 1em;
|
||||
margin-left: 5ex;
|
||||
}
|
||||
|
||||
emu-production.inline {
|
||||
display: inline;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
emu-production.inline emu-rhs {
|
||||
display: inline;
|
||||
padding-left: 1ex;
|
||||
}
|
||||
emu-constraints {
|
||||
font-size: .75em;
|
||||
margin-right: 1ex;
|
||||
}
|
||||
|
||||
emu-gann {
|
||||
margin-right: 1ex;
|
||||
}
|
||||
|
||||
emu-gann emu-t:last-child,
|
||||
emu-gann emu-nt:last-child {
|
||||
margin-right: 0;
|
||||
}
|
||||
|
||||
emu-geq {
|
||||
margin-left: 1ex;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
emu-oneof {
|
||||
font-weight: bold;
|
||||
margin-left: 1ex;
|
||||
}
|
||||
|
||||
emu-nt {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
emu-rhs emu-nt {
|
||||
margin-right: 1ex;
|
||||
}
|
||||
|
||||
emu-t {
|
||||
font-family: monospace;
|
||||
font-weight: bold;
|
||||
margin-right: 1ex;
|
||||
}
|
||||
|
||||
emu-rhs {
|
||||
display: block;
|
||||
padding-left: 50px;
|
||||
}
|
||||
|
||||
emu-mods {
|
||||
font-size: .75em;
|
||||
vertical-align: sub;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
emu-gprose {
|
||||
font-size: 0.9em;
|
||||
font-family: Helvetica, Arial, sans-serif;
|
||||
}
|
||||
|
||||
h1, h2, h3, h4, h5, h6 {
|
||||
position: relative;
|
||||
}
|
||||
h1 .secnum {
|
||||
position: absolute;
|
||||
text-align: right;
|
||||
right: 100%;
|
||||
margin-right: 1ex;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
h1 { font-size: 2.67em; }
|
||||
h2 { font-size: 2em; }
|
||||
h3 { font-size: 1.56em; }
|
||||
h4 { font-size: 1.25em; }
|
||||
h5 { font-size: 1.11em; }
|
||||
h6 { font-size: 1em; }
|
||||
|
||||
emu-intro h1, emu-clause h1, emu-annex h1 { font-size: 2em; }
|
||||
emu-intro h2, emu-clause h2, emu-annex h2 { font-size: 1.56em; }
|
||||
emu-intro h3, emu-clause h3, emu-annex h3 { font-size: 1.25em; }
|
||||
emu-intro h4, emu-clause h4, emu-annex h4 { font-size: 1.11em; }
|
||||
emu-intro h5, emu-clause h5, emu-annex h5 { font-size: 1em; }
|
||||
emu-intro h6, emu-clause h6, emu-annex h6 { font-size: 0.9em; }
|
||||
emu-intro emu-intro h1, emu-clause emu-clause h1, emu-annex emu-annex h1 { font-size: 1.56em; }
|
||||
emu-intro emu-intro h2, emu-clause emu-clause h2, emu-annex emu-annex h2 { font-size: 1.25em; }
|
||||
emu-intro emu-intro h3, emu-clause emu-clause h3, emu-annex emu-annex h3 { font-size: 1.11em; }
|
||||
emu-intro emu-intro h4, emu-clause emu-clause h4, emu-annex emu-annex h4 { font-size: 1em; }
|
||||
emu-intro emu-intro h5, emu-clause emu-clause h5, emu-annex emu-annex h5 { font-size: 0.9em; }
|
||||
emu-intro emu-intro emu-intro h1, emu-clause emu-clause emu-clause h1, emu-annex emu-annex emu-annex h1 { font-size: 1.25em; }
|
||||
emu-intro emu-intro emu-intro h2, emu-clause emu-clause emu-clause h2, emu-annex emu-annex emu-annex h2 { font-size: 1.11em; }
|
||||
emu-intro emu-intro emu-intro h3, emu-clause emu-clause emu-clause h3, emu-annex emu-annex emu-annex h3 { font-size: 1em; }
|
||||
emu-intro emu-intro emu-intro h4, emu-clause emu-clause emu-clause h4, emu-annex emu-annex emu-annex h4 { font-size: 0.9em; }
|
||||
emu-intro emu-intro emu-intro emu-intro h1, emu-clause emu-clause emu-clause emu-clause h1, emu-annex emu-annex emu-annex emu-annex h1 { font-size: 1.11em; }
|
||||
emu-intro emu-intro emu-intro emu-intro h2, emu-clause emu-clause emu-clause emu-clause h2, emu-annex emu-annex emu-annex emu-annex h2 { font-size: 1em; }
|
||||
emu-intro emu-intro emu-intro emu-intro h3, emu-clause emu-clause emu-clause emu-clause h3, emu-annex emu-annex emu-annex emu-annex h3 { font-size: 0.9em; }
|
||||
emu-intro emu-intro emu-intro emu-intro emu-intro h1, emu-clause emu-clause emu-clause emu-clause emu-clause h1, emu-annex emu-annex emu-annex emu-annex emu-annex h1 { font-size: 1em; }
|
||||
emu-intro emu-intro emu-intro emu-intro emu-intro h2, emu-clause emu-clause emu-clause emu-clause emu-clause h2, emu-annex emu-annex emu-annex emu-annex emu-annex h2 { font-size: 0.9em; }
|
||||
emu-intro emu-intro emu-intro emu-intro emu-intro emu-intro h1, emu-clause emu-clause emu-clause emu-clause emu-clause emu-clause h1, emu-annex emu-annex emu-annex emu-annex emu-annex emu-annex h1 { font-size: 0.9em }
|
||||
|
||||
emu-clause {
|
||||
display: block;
|
||||
}
|
||||
|
||||
/* Figures and tables */
|
||||
figure { display: block; margin: 1em 0 3em 0; }
|
||||
figure object { display: block; margin: 0 auto; }
|
||||
figure table.real-table { margin: 0 auto; }
|
||||
figure figcaption {
|
||||
display: block;
|
||||
color: #555555;
|
||||
font-weight: bold;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
table.real-table {
|
||||
border-collapse: collapse;
|
||||
}
|
||||
table.real-table td, table.real-table th {
|
||||
border: 1px solid black;
|
||||
padding: 0.4em;
|
||||
vertical-align: baseline;
|
||||
}
|
||||
table.real-table th {
|
||||
background-color: #eeeeee;
|
||||
}
|
||||
|
||||
/* Note: the left content edges of table.lightweight-table >tbody >tr >td
|
||||
and div.display line up. */
|
||||
table.lightweight-table {
|
||||
border-collapse: collapse;
|
||||
margin: 0 0 0 1.5em;
|
||||
}
|
||||
table.lightweight-table td, table.lightweight-table th {
|
||||
border: none;
|
||||
padding: 0 0.5em;
|
||||
vertical-align: baseline;
|
||||
}
|
||||
|
||||
/* diff styles */
|
||||
ins {
|
||||
background-color: #e0f8e0;
|
||||
text-decoration: none;
|
||||
border-bottom: 1px solid #396;
|
||||
}
|
||||
|
||||
del {
|
||||
background-color: #fee;
|
||||
}
|
||||
|
662
node_modules/reflect-metadata/spec/index-out.html
generated
vendored
Normal file
662
node_modules/reflect-metadata/spec/index-out.html
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
605
node_modules/reflect-metadata/spec/index.html
generated
vendored
Normal file
605
node_modules/reflect-metadata/spec/index.html
generated
vendored
Normal file
@ -0,0 +1,605 @@
|
||||
<meta charset="utf8">
|
||||
<title>Decorators</title>
|
||||
<link rel="stylesheet" href="./css/elements.css">
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.4/styles/github.min.css">
|
||||
<emu-biblio href="./biblio.json"></emu-biblio>
|
||||
|
||||
<h1>Decorators Proposal - ECMAScript</h1>
|
||||
<emu-intro id="introduction">
|
||||
<h1>Introduction</h1>
|
||||
<p>Proposal to add Decorators to ECMAScript.</p>
|
||||
<p>For the TypeScript specific proposal, see <a href="typescript.html">http://rbuckton.github.io/reflectdecorators/typescript.html</a></p>
|
||||
</emu-intro>
|
||||
|
||||
<emu-clause id="proposal-terms">
|
||||
<h1>Terms</h1>
|
||||
<emu-clause id="proposal-terms-decorator">
|
||||
<h1>Decorator</h1>
|
||||
<emu-note>This section is non-normative.</emu-note>
|
||||
<p>A <em>decorator</em> is an expression that is evaluated after a class has been defined, that can be used to annotate or modify the class in some fashion. This expression must evaluate to a <code>function</code>, which is executed by the runtime to apply the decoration.</p>
|
||||
<pre><code class="javascript">@decoratorExpression
|
||||
class C {
|
||||
}
|
||||
</code></pre>
|
||||
</emu-clause>
|
||||
<emu-clause id="proposal-terms-classdecoratorfunction">
|
||||
<h1>Class Decorator Function</h1>
|
||||
<emu-note>This section is non-normative.</emu-note>
|
||||
<p>A <em>class decorator function</em> is a function that accepts a constructor function as its argument, and returns either <code>undefined</code>, the provided constructor function, or a new constructor function. Returning <code>undefined</code> is equivalent to returning the provided constructor function.</p>
|
||||
<pre><code class="javascript">// A class decorator function
|
||||
function dec(target) {
|
||||
// modify, annotate, or replace target...
|
||||
}
|
||||
</code></pre>
|
||||
</emu-clause>
|
||||
<emu-clause id="proposal-terms-propertydecoratorfunction">
|
||||
<h1>Property/Method Decorator Function</h1>
|
||||
<emu-note>This section is non-normative.</emu-note>
|
||||
<p>A <em>property decorator function</em> is a function that accepts three arguments: The object that owns the property, the key for the property (a <code>string</code> or a <code>symbol</code>), and optionally the property descriptor of the property. The function must return either <code>undefined</code>, the provided property descriptor, or a new property descriptor. Returning <code>undefined</code> is equivalent to returning the provided property descriptor.</p>
|
||||
<pre><code class="javascript">// A property (or method/accessor) decorator function
|
||||
function dec(target, key, descriptor) {
|
||||
// annotate the target and key; or modify or replace the descriptor...
|
||||
}
|
||||
</code></pre>
|
||||
</emu-clause>
|
||||
<emu-clause id="proposal-terms-decoratorfactory">
|
||||
<h1>Decorator Factory</h1>
|
||||
<emu-note>This section is non-normative.</emu-note>
|
||||
<p>A <em>decorator factory</em> is a function that can accept any number of arguments, and must return one of the above types of decorator function.</p>
|
||||
<pre><code class="javascript">// a class decorator factory function
|
||||
function dec(x, y) {
|
||||
// the class decorator function
|
||||
return function (target) {
|
||||
// modify, annotate, or replace target...
|
||||
}
|
||||
}
|
||||
</code></pre>
|
||||
</emu-clause>
|
||||
</emu-clause>
|
||||
<emu-clause id="proposal-decoratortargets">
|
||||
<h1>Decorator Targets</h1>
|
||||
<emu-note>This section is non-normative.</emu-note>
|
||||
<p>A <em>decorator</em> <strong>can</strong> be legally applied to any of the following:</p>
|
||||
<ul>
|
||||
<li>A class declaration</li>
|
||||
<li>A class property initializer (static or prototype)</li>
|
||||
<li>A class method declaration (static or prototype)</li>
|
||||
<li>A class get or set accessor declaration (static or prototype)</li>
|
||||
</ul>
|
||||
<p>Please note that a <em>decorator</em> currently <strong>cannot</strong> be legally applied to any of the following:</p>
|
||||
<ul>
|
||||
<li>A class constructor - This is to reduce ambiguity between where you can apply a decorator (on the class or on its constructor) and which of the above decorator function forms is called.</li>
|
||||
<li>A function declaration - Decorators on a function declaration would introduce a TDZ (Temporal Dead Zone), which would make the function unreachable until its declaration is executed. This could cause confusion as an undecorated function declaration is hoisted and can be used in a statement preceeding the declaration.</li>
|
||||
<li>A function expression - This is to reduce confusion and maintain parity with disallowing decorators on a function declaration.</li>
|
||||
<li>An arrow function - This is to reduce confusion and maintain parity with disallowing decorators on a function expression.</li>
|
||||
</ul>
|
||||
<p>This list may change in the future.</p>
|
||||
</emu-clause>
|
||||
<emu-clause id="proposal-decoratoreval">
|
||||
<h1>Decorator Evaluation and Application Order</h1>
|
||||
<emu-note>This section is non-normative.</emu-note>
|
||||
<p>Decorators are <em>evaluated</em> in the order they appear preceeding their target declaration, to preserve side-effects due to evaluation order. Decorators are <em>applied</em> to their target declaration in reverse order, starting with the decorator closest to the declaration. This behavior is specified to preserve the expected behavior of decorators without a declarative syntax.</p>
|
||||
<pre><code class="javascript">@F
|
||||
@G
|
||||
class C {
|
||||
}
|
||||
</code></pre>
|
||||
<p>For example, the above listing could be approximately written without decorators in the following fashion:</p>
|
||||
<pre><code class="javascript">C = F(G(C))</code></pre>
|
||||
<p>In the above example, the expression <code>F</code> is evaluated first, followed by the expression <code>G</code>. <code>G</code> is then called with the constructor function as its argument, followed by calling <code>F</code> with the result. The actual process of applying decorators is more complex than the above example however, though you may still imperatively apply decorators with a reflection API.</p>
|
||||
<p>If a class declaration has decorators on both the class and any of its members or parameters, the decorators are applied using the following pseudocode:</p>
|
||||
<pre>
|
||||
for each member M of class C
|
||||
if M is an accessor then
|
||||
let accessor = first accessor (get or set, in declaration order) of M
|
||||
let memberDecorators = decorators of accessor
|
||||
for each parameter of accessor
|
||||
let paramDecorators = decorators of parameter
|
||||
let paramIndex = ordinal index of parameter
|
||||
Reflect.decorate(paramDecorators, accessor, paramIndex)
|
||||
next parameter
|
||||
|
||||
let accessor = second accessor (get or set, in declaration order) of M
|
||||
if accessor then
|
||||
let memberDecorators = memberDecorators + decorators of accessor
|
||||
for each parameter of accessor
|
||||
let paramDecorators = decorators of parameter
|
||||
let paramIndex = ordinal index of parameter
|
||||
Reflect.decorate(paramDecorators, accessor, paramIndex)
|
||||
next parameter
|
||||
end if
|
||||
else if M is a method
|
||||
let memberDecorators = decorators of M
|
||||
for each parameter of M
|
||||
let paramDecorators = decorators of parameter
|
||||
let paramIndex = ordinal index of parameter
|
||||
Reflect.decorate(paramDecorators, M, paramIndex)
|
||||
next parameter
|
||||
else
|
||||
let memberDecorators = decorators of M
|
||||
end if
|
||||
|
||||
let name = name of M
|
||||
let target = C.prototype if M is on the prototype; otherwise, C if M is static
|
||||
Reflect.decorate(memberDecorators, C, name)
|
||||
next member
|
||||
|
||||
for each parameter of C
|
||||
let paramDecorators = decorators of parameter
|
||||
let paramIndex = ordinal index of parameter
|
||||
Reflect.decorate(paramDecorators, C, paramIndex)
|
||||
next parameter
|
||||
|
||||
let classDecorators = decorators of C
|
||||
let C = Reflect.decorate(classDecorators, C)
|
||||
</pre>
|
||||
</emu-clause>
|
||||
|
||||
<emu-clause id="operations">
|
||||
<h1>Abstract Operations</h1>
|
||||
<emu-clause id="operations-decoration">
|
||||
<h1>Decorator Operations</h1>
|
||||
<emu-clause id="operations-decoration-decorate">
|
||||
<h1>Decorate ( Decorators, O, P, desc )</h1>
|
||||
<p>When the abstract operation Decorate is called with ECMAScript language value <var>Decorators</var>, Object <var>O</var>, property key <var>P</var>, and property descriptor <var>desc</var>, the following steps are taken:</p>
|
||||
<emu-alg aoid="Decorate">
|
||||
1. If _P_ is *undefined* and _desc_ is *undefined*, then
|
||||
1. If IsCallable(_O_) is not *true*, throw a *TypeError* exception.
|
||||
2. Return DecorateConstructor(_Decorators_, _O_).
|
||||
2. Else
|
||||
1. Return DecorateProperty(_Decorators_, _O_, _P_, _desc_).
|
||||
</emu-alg>
|
||||
</emu-clause>
|
||||
<emu-clause id="operations-decoration-decorateconstructor">
|
||||
<h1>DecorateConstructor ( Decorators, F )</h1>
|
||||
<p>When the abstract operation DecorateConstructor is called with ECMAScript language value <var>Decorators</var> and Object <var>F</var>, the following steps are taken:</p>
|
||||
<emu-alg aoid="DecorateConstructor">
|
||||
1. Let _result_ be _F_.
|
||||
2. Let _iterator_ be GetIterator(_Decorators_).
|
||||
3. Let _list_ be CreateListFromIterator(_iterator_, «Object»).
|
||||
4. For each _decorator_ in _list_ in reverse order
|
||||
1. Let _decorated_ be Call(_decorator_, *null*, _result_).
|
||||
2. ReturnIfAbrupt(_decorated_).
|
||||
3. If IsCallable(_decorated_), then
|
||||
1. Set _result_ to be _decorated_.
|
||||
4. Else if _decorated_ is not *undefined*, throw a *TypeError* exception.
|
||||
</emu-alg>
|
||||
</emu-clause>
|
||||
<emu-clause id="operations-decoration-decorateproperty">
|
||||
<h1>DecorateProperty ( Decorators, O, P, desc )</h1>
|
||||
<p>When the abstract operation DecorateProperty is called with ECMAScript language value <var>Decorators</var>, Object <var>O</var>, property key <var>P</var>, and property descriptor <var>desc</var>, the following steps are taken:</p>
|
||||
<emu-alg aoid="DecorateProperty">
|
||||
1. Let _result_ be _desc_.
|
||||
2. Let _key_ be ToPropertyKey(_P_).
|
||||
3. Let _iterator_ be GetIterator(_Decorators_).
|
||||
4. Let _list_ be CreateListFromIterator(_iterator_, «Object»).
|
||||
5. For each _decorator_ in _list_ in reverse order
|
||||
6. Let _decorated_ be Call(_decorator_, *null*, _O_, _key_, _result_).
|
||||
7. ReturnIfAbrupt(_decorated_).
|
||||
8. If Type(_decorated_) is Object, then
|
||||
1. Set _result_ to be _decorated_.
|
||||
9. Else if _decorated_ is not *undefined*, throw a *TypeError* exception.
|
||||
</emu-alg>
|
||||
</emu-clause>
|
||||
</emu-clause>
|
||||
<emu-clause id="operations-object">
|
||||
<h1>Operations on Objects</h1>
|
||||
<emu-clause id="createlistfromiterator">
|
||||
<h1>CreateListFromIterator ( iterator [, elementTypes] )</h1>
|
||||
<p>When the abstract operation CreateListFromIterator is called with ECMAScript language value <var>iterator</var>, the following steps are taken:</p>
|
||||
<emu-alg aoid="CreateListFromIterator">
|
||||
1. ReturnIfAbrupt(_iterator_).
|
||||
2. If _elementTypes_ was not passed, let _elementTypes_ be (Undefined, Null, Boolean, String, Symbol, Number, Object).
|
||||
3. Let _list_ be an empty List.
|
||||
4. Repeat
|
||||
1. Let _next_ be IteratorStep(_iterator_).
|
||||
2. ReturnIfAbrupt(_next_).
|
||||
3. If _next_ is *false*, return _list_.
|
||||
4. Let _nextValue_ be IteratorValue(_next_).
|
||||
5. ReturnIfAbrupt(_nextValue_).
|
||||
6. If Type(_nextValue_) is not an element of _elementTypes_, then
|
||||
1. Return IteratorClose(_iterator_, Completion{[[type]]: throw, [[value]]: a newly created *TypeError* object, [[target]: empty}).
|
||||
7. Append _nextValue_ as the last element of _list_.
|
||||
</emu-alg>
|
||||
</emu-clause>
|
||||
<emu-clause id="getorcreatemetadatamap">
|
||||
<h1>GetOrCreateMetadataMap ( O, P, Create )</h1>
|
||||
<p>When the abstract operation GetOrCreateMetadataMap is called with Object <var>O</var>, property key <var>P</var>, and Boolean <var>Create</var> the following steps are taken:</p>
|
||||
<emu-alg aoid="GetOrCreateMetadataMap">
|
||||
1. Assert: _P_ is *undefined* or IsPropertyKey(_P_) is *true*.
|
||||
2. Let _metadataMap_ be *undefined*.
|
||||
3. Let _succeeded_ be *true*.
|
||||
4. Let _targetMetadata_ be the value of _O_'s [[Metadata]] internal slot.
|
||||
5. If _targetMetadata_ is *undefined*, then
|
||||
1. If _Create_ is *false*, return *undefined*.
|
||||
2. Set _targetMetadata_ to be a newly created *Map* object.
|
||||
3. Set the [[Metadata]] internal slot of _O_ to _targetMetadata_.
|
||||
6. Let _metadataMap_ be Invoke(_targetMetadata_, "get", _P_).
|
||||
7. ReturnIfAbrupt(_metadataMap_).
|
||||
8. If _metadataMap_ is *undefined*, then
|
||||
1. If _Create_ is *false*, return *undefined*.
|
||||
2. Set _metadataMap_ to be a newly created *Map* object.
|
||||
3. Let _setStatus_ be Invoke(_targetMetadata_, "set", _P_, _metadataMap_).
|
||||
4. ReturnIfAbrupt(_setStatus_).
|
||||
9. Return _metadataMap_.
|
||||
</emu-alg>
|
||||
</emu-clause>
|
||||
<emu-clause id="hasmetadata">
|
||||
<h1>[[HasMetadata]] ( MetadataKey, P )</h1>
|
||||
<p>When the [[HasMetadata]] internal method of _O_ is called with ECMAScript language value <var>MetadataKey</var> and property key <var>P</var>, the following steps are taken:</p>
|
||||
<emu-alg>
|
||||
1. Return OrdinaryHasMetadata(_MetadataKey_, _O_, _P_).
|
||||
</emu-alg>
|
||||
</emu-clause>
|
||||
<emu-clause id="ordinaryhasmetadata">
|
||||
<h1>OrdinaryHasMetadata ( MetadataKey, O, P )</h1>
|
||||
<p>When the abstract operation OrdinaryHasMetadata is called with ECMAScript language value <var>MetadataKey</var>, Object <var>O</var>, and property key <var>P</var>, the following steps are taken:</p>
|
||||
<emu-alg aoid="OrdinaryHasMetadata">
|
||||
1. Assert: _P_ is *undefined* or IsPropertyKey(_P_) is *true*.
|
||||
2. Let _hasOwn_ be OrdinaryHasOwnMetadata(_MetadataKey_, _O_, _P_).
|
||||
3. If _hasOwn_ is *true*, return *true*.
|
||||
4. Let _parent_ be _O_.[[GetPrototypeOf]]().
|
||||
5. ReturnIfAbrupt(_parent_).
|
||||
6. If _parent_ is not *null*, then
|
||||
1. return <var>parent</var>.[[HasMetadata]](_MetadataKey_, _P_).
|
||||
7. Return *false*.
|
||||
</emu-alg>
|
||||
</emu-clause>
|
||||
<emu-clause id="hasownmetadata">
|
||||
<h1>[[HasOwnMetadata]] ( MetadataKey, P )</h1>
|
||||
<p>When the [[HasOwnMetadata]] internal method of _O_ is called with ECMAScript language value <var>MetadataKey</var> and property key <var>P</var>, the following steps are taken:</p>
|
||||
<emu-alg>
|
||||
1. Return OrdinaryHasOwnMetadata(_MetadataKey_, _O_, _P_).
|
||||
</emu-alg>
|
||||
</emu-clause>
|
||||
<emu-clause id="ordinaryhasownmetadata">
|
||||
<h1>OrdinaryHasOwnMetadata ( MetadataKey, O, P )</h1>
|
||||
<p>When the abstract operation OrdinaryHasOwnMetadata is called with ECMAScript language value <var>MetadataKey</var>, Object <var>O</var>, and property key <var>P</var>, the following steps are taken:</p>
|
||||
<emu-alg aoid="OrdinaryHasOwnMetadata">
|
||||
1. Assert: _P_ is *undefined* or IsPropertyKey(_P_) is *true*.
|
||||
2. Let _metadataMap_ be GetOrCreateMetadataMap(_O_, _P_, *false*).
|
||||
3. ReturnIfAbrupt(_metadataMap_).
|
||||
4. If _metadataMap_ is *undefined*, return *false*.
|
||||
5. Return Invoke(_metadataMap_, "has", _MetadataKey_).
|
||||
</emu-alg>
|
||||
</emu-clause>
|
||||
<emu-clause id="getmetadata">
|
||||
<h1>[[GetMetadata]] ( MetadataKey, P )</h1>
|
||||
<p>When the [[GetMatadata]] internal method of _O_ is called with ECMAScript language value <var>MetadataKey</var> and property key <var>P</var>, the following steps are taken:</p>
|
||||
<emu-alg>
|
||||
1. Return OrdinaryGetMetadata(_MetadataKey_, _O_, _P_).
|
||||
</emu-alg>
|
||||
</emu-clause>
|
||||
<emu-clause id="ordinarygetmetadata">
|
||||
<h1>OrdinaryGetMetadata ( MetadataKey, O, P )</h1>
|
||||
<p>When the abstract operation OrdinaryGetMetadata is called with ECMAScript language value <var>MetadataKey</var>, Object <var>O</var>, and property key <var>P</var>, the following steps are taken:</p>
|
||||
<emu-alg aoid="OrdinaryGetMetadata">
|
||||
1. Assert: _P_ is *undefined* or IsPropertyKey(_P_) is *true*.
|
||||
2. Let _hasOwn_ be OrdinaryHasOwnMetadata(_MetadataKey_, _O_, _P_).
|
||||
3. If _hasOwn_ is *true*, then
|
||||
1. return OrdinaryGetOwnMetadata(_MetadataKey_, _O_, _P_).
|
||||
4. Let _parent_ be _O_.[[GetPrototypeOf]]().
|
||||
5. ReturnIfAbrupt(_parent_).
|
||||
6. If _parent_ is not *null*, then
|
||||
1. return <var>parent</var>.[[GetMetadata]](_MetadataKey_, _P_).
|
||||
7. Return *undefined*.
|
||||
</emu-alg>
|
||||
</emu-clause>
|
||||
<emu-clause id="getownmetadata">
|
||||
<h1>[[GetOwnMetadata]] ( MetadataKey, P, ParamIndex )</h1>
|
||||
<p>When the [[GetOwnMetadata]] internal method of _O_ is called with ECMAScript language value <var>MetadataKey</var> and property key <var>P</var>, the following steps are taken:</p>
|
||||
<emu-alg>
|
||||
1. Return OrdinaryGetOwnMetadata(_MetadataKey_, _O_, _P_).
|
||||
</emu-alg>
|
||||
</emu-clause>
|
||||
<emu-clause id="ordinarygetownmetadata">
|
||||
<h1>OrdinaryGetOwnMetadata ( MetadataKey, O, P )</h1>
|
||||
<p>When the abstract operation OrdinaryGetOwnMetadata is called with ECMAScript language value <var>MetadataKey</var>, Object <var>O</var>, and property key <var>P</var>, the following steps are taken:</p>
|
||||
<emu-alg aoid="OrdinaryGetOwnMetadata">
|
||||
1. Assert: _P_ is *undefined* or IsPropertyKey(_P_) is *true*.
|
||||
2. Let _metadataMap_ be GetOrCreateMetadataMap(_O_, _P_, *false*).
|
||||
3. ReturnIfAbrupt(_metadataMap_).
|
||||
4. If _metadataMap_ is *undefined*, return *undefined*.
|
||||
5. Return Invoke(_metadataMap_, "get", _MetadataKey_).
|
||||
</emu-alg>
|
||||
</emu-clause>
|
||||
<emu-clause id="defineownmetadata">
|
||||
<h1>[[DefineOwnMetadata]] ( MetadataKey, MetadataValue, P )</h1>
|
||||
<p>When the [[DefineOwnMetadata]] internal method of _O_ is called with ECMAScript language value <var>MetadataKey</var>, ECMAScript language value <var>MetadataValue</var>, and property key <var>P</var>, the following steps are taken:</p>
|
||||
<emu-alg>
|
||||
1. Return OrdinaryDefineOwnMetadata(_MetadataKey_, _MetadataValue_, _O_, _P_)
|
||||
</emu-alg>
|
||||
</emu-clause>
|
||||
<emu-clause id="ordinarydefineownmetadata">
|
||||
<h1>OrdinaryDefineOwnMetadata ( MetadataKey, MetadataValue, O, P )</h1>
|
||||
<p>When the abstract operation OrdinaryDefineOwnProperty is called with ECMAScript language value <var>MetadataKey</var>, ECMAScript language value <var>MetadataValue</var>, Object <var>O</var>, and property key <var>P</var>, the following steps are taken:</p>
|
||||
<emu-alg aoid="OrdinaryDefineOwnMetadata">
|
||||
1. Assert: _P_ is *undefined* or IsPropertyKey(_P_) is *true*.
|
||||
2. Let _metadataMap_ be GetOrCreateMetadataMap(_O_, _P_, *true*).
|
||||
3. ReturnIfAbrupt(_metadataMap_).
|
||||
4. Return Invoke(_metadataMap_, "set", _MetadataKey_, _MetadataValue_).
|
||||
</emu-alg>
|
||||
</emu-clause>
|
||||
<emu-clause id="metadatakeys">
|
||||
<h1>[[MetadataKeys]] ( P )</h1>
|
||||
<p>When the [[MetadataKeys]] internal method of <var>O</var> is called with property key <var>P</var> the following steps are taken:</p>
|
||||
<emu-alg>
|
||||
1. Return OrdinaryMetadataKeys(_O_, _P_).
|
||||
</emu-alg>
|
||||
</emu-clause>
|
||||
<emu-clause id="ordinarymetadatakeys">
|
||||
<h1>OrdinaryMetadataKeys ( O, P )</h1>
|
||||
<p>When the abstract operation OrdinaryMetadataKeys is called with Object <var>O</var> and property key <var>P</var> the following steps are taken:</p>
|
||||
<emu-alg aoid="OrdinaryMetadataKeys">
|
||||
1. Assert: _P_ is *undefined* or IsPropertyKey(_P_) is *true*.
|
||||
2. Let _ownKeys_ be OrdinaryOwnMetadataKeys(_O_, _P_).
|
||||
3. Let _parent_ = _O_.[[GetPrototypeOf]]().
|
||||
4. ReturnIfAbrupt(_parent_).
|
||||
5. If _parent_ is *null*, then return _ownKeys_.
|
||||
6. Let _parentKeys_ be <var>O</var>.[[OrdinaryMetadataKeys]](_P_).
|
||||
7. ReturnIfAbrupt(_parentKeys_).
|
||||
8. Let _ownKeysLen_ = Get(_ownKeys_, "length").
|
||||
9. ReturnIfAbrupt(_ownKeysLen_).
|
||||
10. If _ownKeysLen_ is 0, return _parentKeys_.
|
||||
11. Let _parentKeysLen_ = Get(_parentKeys_, "length").
|
||||
12. ReturnIfAbrupt(_parentKeysLen_).
|
||||
13. If _parentKeysLen_ is 0, return _ownKeys_.
|
||||
14. Let _set_ be a newly created *Set* object.
|
||||
15. Let _keys_ be ArrayCreate(0).
|
||||
16. Let _k_ be 0.
|
||||
17. For each element _key_ of _ownKeys_
|
||||
1. Let _hasKey_ be Invoke(_set_, "has", _key_).
|
||||
2. ReturnIfAbrupt(_hasKey_).
|
||||
3. If _hasKey_ is *false*, then
|
||||
1. Let _Pk_ be ToString(_k_).
|
||||
2. Let _addStatus_ be Invoke(_set_, "add", _key_).
|
||||
3. ReturnIfAbrupt(_addStatus_).
|
||||
4. Let _defineStatus_ be CreateDataPropertyOrThrow(_keys_, _Pk_, _key_).
|
||||
5. ReturnIfAbrupt(_defineStatus_).
|
||||
6. Increase _k_ by 1.
|
||||
18. For each element _key_ of _parentKeys_
|
||||
1. Let _hasKey_ be Invoke(_set_, "has", _key_).
|
||||
2. ReturnIfAbrupt(_hasKey_).
|
||||
3. If _hasKey_ is *false*, then
|
||||
1. Let _Pk_ be ToString(_k_).
|
||||
2. Let _addStatus_ be Invoke(_set_, "add", _key_).
|
||||
3. ReturnIfAbrupt(_addStatus_).
|
||||
4. Let _defineStatus_ be CreateDataPropertyOrThrow(_keys_, _Pk_, _key_).
|
||||
5. ReturnIfAbrupt(_defineStatus_).
|
||||
6. Increase _k_ by 1.
|
||||
19. Let _setStatus_ be Set(_keys_, "length", _k_).
|
||||
20. ReturnIfAbrupt(_setStatus_).
|
||||
21. return _keys_.
|
||||
</emu-alg>
|
||||
</emu-clause>
|
||||
<emu-clause id="ownmetadatakeys">
|
||||
<h1>[[OwnMetadataKeys]] ( P )</h1>
|
||||
<p>When the [[OwnMetadataKeys]] internal method of <var>O</var> is called with property key <var>P</var> the following steps are taken:</p>
|
||||
<emu-alg>
|
||||
1. Return OrdinaryOwnMetadataKeys(_O_, _P_).
|
||||
</emu-alg>
|
||||
</emu-clause>
|
||||
<emu-clause id="ordinaryownmetadatakeys">
|
||||
<h1>OrdinaryOwnMetadataKeys ( O, P )</h1>
|
||||
<p>When the abstract operation OrdinaryOwnMetadataKeys is called with Object <var>O</var> and property key <var>P</var> the following steps are taken:</p>
|
||||
<emu-alg aoid="OrdinaryOwnMetadataKeys">
|
||||
1. Assert: _P_ is *undefined* or IsPropertyKey(_P_) is *true*.
|
||||
2. Let _keys_ be ArrayCreate(0).
|
||||
3. Let _metadataMap_ be GetOrCreateMetadataMap(_O_, _P_, *false*).
|
||||
4. ReturnIfAbrupt(_metadataMap_).
|
||||
5. If _metadataMap_ is *undefined*, return _keys_.
|
||||
6. Let _keysObj_ be Invoke(_metadataMap_, "keys").
|
||||
7. ReturnIfAbrupt(_keysObj_).
|
||||
8. Let _iterator_ be GetIterator(_keysObj_).
|
||||
9. ReturnIfAbrupt(_iterator_).
|
||||
10. Let _k_ be 0.
|
||||
11. Repeat
|
||||
1. Let _Pk_ be ToString(k).
|
||||
2. Let _next_ be IteratorStep(_iterator_).
|
||||
3. ReturnIfAbrupt(_next_).
|
||||
4. If _next_ is *false*, then
|
||||
1. Let _setStatus_ be Set(_keys_, "length", _k_, _true_).
|
||||
2. ReturnIfAbrupt(_setStatus_).
|
||||
3. Return _keys_.
|
||||
5. Let _nextValue_ be IteratorValue(_next_).
|
||||
6. ReturnIfAbrupt(_nextValue_).
|
||||
7. Let _defineStatus_ be CreateDataPropertyOrThrow(_keys_, _Pk_, _nextValue_).
|
||||
8. If _defineStatus_ is an abrupt completion, return IteratorClose(_iterator_, _defineStatus_).
|
||||
9. Increase _k_ by 1.
|
||||
</emu-alg>
|
||||
</emu-clause>
|
||||
<emu-clause id="deletemetadata">
|
||||
<h1>[[DeleteMetadata]]( MetadataKey, P )</h1>
|
||||
<p>When the [[DeleteMetadata]] internal method of <var>O</var> is called with ECMAScript language value <var>MetadataKey</var> and property key <var>P</var> the following steps are taken:</p>
|
||||
<emu-alg>
|
||||
1. Assert: _P_ is *undefined* or IsPropertyKey(_P_) is *true*.
|
||||
2. Let _metadataMap_ be GetOrCreateMetadataMap(_O_, _P_, *false*).
|
||||
3. ReturnIfAbrupt(_metadataMap_).
|
||||
4. If _metadataMap_ is *undefined*, return *false*.
|
||||
5. Return Invoke(_metadataMap_, "delete", _MetadataKey_).
|
||||
</emu-alg>
|
||||
</emu-clause>
|
||||
</emu-clause>
|
||||
</emu-clause>
|
||||
|
||||
<emu-clause id="reflection">
|
||||
<h1>Reflection</h1>
|
||||
<emu-clause id="reflect">
|
||||
<h1>The Reflect Object</h1>
|
||||
<p>This section contains amendments to the Reflect object.</p>
|
||||
<emu-note>A shim for this API can be found here: <a href="https://github.com/rbuckton/ReflectDecorators">https://github.com/rbuckton/ReflectDecorators</a></emu-note>
|
||||
<emu-clause id="reflect-metadatadecoratorfunctions">
|
||||
<h1>Metadata Decorator Functions</h1>
|
||||
<p>A metadata decorator function is an anonymous built-in function that has [[MetadataKey]] and [[MetadataValue]] internal slots.</p>
|
||||
<p>When a metadata decorator function <var>F</var> is called with arguments <var>target</var> and <var>key</var>, the following steps are taken:</p>
|
||||
<emu-alg>
|
||||
1. Assert: _F_ has a [[MetadataKey]] internal slot whose value is an ECMAScript language value, or *undefined*.
|
||||
2. Assert: _F_ has a [[MetadataValue]] internal slot whose value is an ECMAScript language value, or *undefined*.
|
||||
3. If Type(_target_) is not Object, throw a *TypeError* exception.
|
||||
4. If _key_ is not *undefined* and IsPropertyKey(_key_) is *false*, throw a *TypeError* exception.
|
||||
5. Let _metadataKey_ be the value of _F_'s [[MetadataKey]] internal slot.
|
||||
6. Let _metadataValue_ be the value of _F_'s [[MetadataValue]] internal slot.
|
||||
7. Return <var>target</var>.[[DefineMetadata]](_metadataKey_, _metadataValue_, _target_, _key_).
|
||||
</emu-alg>
|
||||
</emu-clause>
|
||||
<emu-clause id="reflect-decorate">
|
||||
<h1>Reflect.decorate ( decorators, target, propertyKey, attributes )</h1>
|
||||
<p>When the <code>decorator</code> function is called with arguments <var>decorators</var>, <var>target</var>, <var>propertyKey</var>, and <var>attributes</var>, the following steps are taken:</p>
|
||||
<emu-alg>
|
||||
1. If Type(_decorators_) is not Object, throw a *TypeError* exception.
|
||||
2. If Type(_target_) is not Object, throw a *TypeError* exception.
|
||||
3. Let _key_ be ToPropertyKey(_propertyKey_).
|
||||
4. ReturnIfAbrupt(_propertyKey_).
|
||||
5. Let _desc_ be ToPropertyDescriptor(_attributes_).
|
||||
6. ReturnIfAbrupt(_desc_).
|
||||
7. Return Decorate(_decorators_, _target_, _propertyKey_, _desc_).
|
||||
</emu-alg>
|
||||
</emu-clause>
|
||||
<emu-clause id="reflect-metadata">
|
||||
<h1>Reflect.metadata ( metadataKey, metadataValue )</h1>
|
||||
<p>When the <code>metadata</code> function is called with arguments <var>metadataKey</var> and <var>metadataValue</var>, the following steps are taken:</p>
|
||||
<emu-alg>
|
||||
1. Let _decorator_ be a new built-in function object as defined in Metadata Decorator Functions.
|
||||
2. Set the [[MetadataKey]] internal slot of _decorator_ to _metadataKey_.
|
||||
3. Set the [[MetadataValue]] internal slot of _decorator_ to _metadataValue_.
|
||||
4. return _decorator_.
|
||||
</emu-alg>
|
||||
</emu-clause>
|
||||
<emu-clause id="reflect-definemetadata">
|
||||
<h1>Reflect.defineMetadata ( metadataKey, metadataValue, target, propertyKey )</h1>
|
||||
<p>When the <code>defineMetadata</code> function is called with arguments <var>metadataKey</var>, <var>metadataValue</var>, <var>target</var>, and <var>propertyKey</var>, the following steps are taken:</p>
|
||||
<emu-alg>
|
||||
1. If Type(_target_) is not Object, throw a *TypeError* exception.
|
||||
2. return <var>target</var>.[[DefineMetadata]](_metadataKey_, _metadataValue_, _propertyKey_).
|
||||
</emu-alg>
|
||||
</emu-clause>
|
||||
<emu-clause id="reflect-hasmetadata">
|
||||
<h1>Reflect.hasMetadata ( metadataKey, target, propertyKey )</h1>
|
||||
<p>When the <code>hasMetadata</code> function is called with arguments <var>metadataKey</var>, <var>target</var>, and <var>propertyKey</var>, the following steps are taken:</p>
|
||||
<emu-alg>
|
||||
1. If Type(_target_) is not Object, throw a *TypeError* exception.
|
||||
2. return <var>target</var>.[[HasMetadata]](_metadataKey_, _propertyKey_).
|
||||
</emu-alg>
|
||||
</emu-clause>
|
||||
<emu-clause id="reflect-hasownmetadata">
|
||||
<h1>Reflect.hasOwnMetadata ( metadataKey, target, propertyKey )</h1>
|
||||
<p>When the <code>hasOwnMetadata</code> function is called with arguments <var>metadataKey</var>, <var>target</var>, and <var>propertyKey</var>, the following steps are taken:</p>
|
||||
<emu-alg>
|
||||
1. If Type(_target_) is not Object, throw a *TypeError* exception.
|
||||
2. return <var>target</var>.[[HasOwn]](_metadataKey_, _propertyKey_).
|
||||
</emu-alg>
|
||||
</emu-clause>
|
||||
<emu-clause id="reflect-getmetadata">
|
||||
<h1>Reflect.getMetadata ( metadataKey, target, propertyKey )</h1>
|
||||
<p>When the <code>getMetadata</code> function is called with arguments <var>metadataKey</var>, <var>target</var>, and <var>propertyKey</var>, the following steps are taken:</p>
|
||||
<emu-alg>
|
||||
1. If Type(_target_) is not Object, throw a *TypeError* exception.
|
||||
2. return <var>target</var>.[[GetMetadata]](_metadataKey_, _propertyKey_).
|
||||
</emu-alg>
|
||||
</emu-clause>
|
||||
<emu-clause id="reflect-getownmetadata">
|
||||
<h1>Reflect.getOwnMetadata ( metadataKey, target, propertyKey )</h1>
|
||||
<p>When the <code>getOwnMetadata</code> function is called with arguments <var>metadataKey</var>, <var>target</var>, and <var>propertyKey</var>, the following steps are taken:</p>
|
||||
<emu-alg>
|
||||
1. If Type(_target_) is not Object, throw a *TypeError* exception.
|
||||
2. return <var>target</var>.[[GetOwnMetadata]](_metadataKey_, _propertyKey_).
|
||||
</emu-alg>
|
||||
</emu-clause>
|
||||
<emu-clause id="reflect-getmetadatakeys">
|
||||
<h1>Reflect.getMetadataKeys ( target, propertyKey )</h1>
|
||||
<p>When the <code>getMetadataKeys</code> function is called with arguments <var>target</var> and <var>propertyKey</var>, the following steps are taken:</p>
|
||||
<emu-alg>
|
||||
1. If Type(_target_) is not Object, throw a *TypeError* exception.
|
||||
2. return <var>target</var>.[[GetMetadataKeys]](_propertyKey_).
|
||||
</emu-alg>
|
||||
</emu-clause>
|
||||
<emu-clause id="reflect-getownmetadata">
|
||||
<h1>Reflect.getOwnMetadataKeys ( target, propertyKey )</h1>
|
||||
<p>When the <code>getOwnMetadataKeys</code> function is called with arguments <var>target</var> and <var>propertyKey</var>, the following steps are taken:</p>
|
||||
<emu-alg>
|
||||
1. If Type(_target_) is not Object, throw a *TypeError* exception.
|
||||
2. return <var>target</var>.[[GetOwnMetadataKeys]](_propertyKey_).
|
||||
</emu-alg>
|
||||
</emu-clause>
|
||||
<emu-clause id="reflect-deletemetadata">
|
||||
<h1>Reflect.deleteMetadata ( metadataKey, target, propertyKey )</h1>
|
||||
<p>When the <code>deleteMetadata</code> function is called with arguments <var>metadataKey</var>, <var>target</var>, and <var>propertyKey</var>, the following steps are taken:</p>
|
||||
<emu-alg>
|
||||
1. If Type(_target_) is not Object, throw a *TypeError* exception.
|
||||
2. return <var>target</var>.[[DeleteMetadata]](_metadataKey_, _propertyKey_).
|
||||
</emu-alg>
|
||||
</emu-clause>
|
||||
</emu-clause>
|
||||
</emu-clause>
|
||||
<emu-annex id="grammar">
|
||||
<h1>Grammar</h1>
|
||||
<emu-annex id="grammar-expressions">
|
||||
<h1>Expressions</h1>
|
||||
<emu-production id="grammar-memberexpression" name="MemberExpression" params="Yield, Decorator">
|
||||
<emu-rhs><emu-nt params="?Yield">PrimaryExpression</emu-nt></emu-rhs>
|
||||
<emu-rhs constraints="~Decorator"><emu-nt params="?Yield, ?Decorator">MemberExpression</emu-nt><emu-t>[</emu-t><emu-nt params="In, ?Yield">Expression</emu-nt><emu-t>]</emu-t></emu-rhs>
|
||||
<emu-rhs><emu-nt params="?Yield, ?Decorator">MemberExpression</emu-nt><emu-t>.</emu-t><emu-nt>IdentifierName</emu-nt></emu-rhs>
|
||||
<emu-rhs><emu-nt params="?Yield, ?Decorator">MemberExpression</emu-nt><emu-nt params="?Yield">TemplateLiteral</emu-nt></emu-rhs>
|
||||
<emu-rhs><emu-nt params="?Yield, ?Decorator">SuperProperty</emu-nt></emu-rhs>
|
||||
<emu-rhs><emu-nt>MetaProperty</emu-nt></emu-rhs>
|
||||
<emu-rhs><emu-t>new</emu-t><emu-nt params="?Yield, ?Decorator">MemberExpression</emu-nt><emu-nt params="?Yield">Arguments</emu-nt></emu-rhs>
|
||||
</emu-production>
|
||||
<emu-production id="grammar-superproperty" name="SuperProperty" params="Yield, Decorator">
|
||||
<emu-rhs constraints="~Decorator"><emu-t>super</emu-t><emu-t>[</emu-t><emu-nt params="In, ?Yield">Expression</emu-nt><emu-t>]</emu-t></emu-rhs>
|
||||
</emu-production>
|
||||
<emu-production id="grammar-newexpression" name="NewExpression" params="Yield, Decorator">
|
||||
<emu-rhs><emu-nt params="?Yield, ?Decorator">MemberExpression</emu-nt></emu-rhs>
|
||||
<emu-rhs><emu-t>new</emu-t><emu-nt params="?Yield, ?Decorator">NewExpression</emu-nt></emu-rhs>
|
||||
</emu-production>
|
||||
<emu-production id="grammar-callexpression" name="CallExpression" params="Yield, Decorator">
|
||||
<emu-rhs><emu-nt params="?Yield, ?Decorator">MemberExpression</emu-nt> <emu-nt params="?Yield">Arguments</emu-nt></emu-rhs>
|
||||
<emu-rhs><emu-nt params="?Yield">SuperCall</emu-nt></emu-rhs>
|
||||
<emu-rhs><emu-nt params="?Yield, ?Decorator">CallExpression</emu-nt> <emu-nt params="?Yield">Arguments</emu-nt></emu-rhs>
|
||||
<emu-rhs constraints="~Decorator"><emu-nt params="?Yield">CallExpression</emu-nt> <emu-t>[</emu-t> <emu-nt params="In, ?Yield">Expression</emu-nt> <emu-t>]</emu-t></emu-rhs>
|
||||
<emu-rhs><emu-nt params="?Yield, ?Decorator">CallExpression</emu-nt> <emu-t>.</emu-t> <emu-nt>IdentifierName</emu-nt></emu-rhs>
|
||||
<emu-rhs><emu-nt params="?Yield, ?Decorator">CallExpression</emu-nt> <emu-nt params="?Yield">TemplateLiteral</emu-nt></emu-rhs>
|
||||
</emu-production>
|
||||
<emu-production id="grammar-lefthandsideexpression" name="LeftHandSideExpression" params="Yield, Decorator">
|
||||
<emu-rhs><emu-nt params="?Yield, ?Decorator">NewExpression</emu-nt></emu-rhs>
|
||||
<emu-rhs><emu-nt params="?Yield, ?Decorator">CallExpression</emu-nt></emu-rhs>
|
||||
</emu-production>
|
||||
</emu-annex>
|
||||
|
||||
<emu-annex id="functions-and-classes">
|
||||
<h1>Functions and Classes</h1>
|
||||
<emu-production id="grammar-classdeclaration" name="ClassDeclaration" params="Yield, Default">
|
||||
<emu-rhs><emu-nt params="?Yield" optional>DecoratorList</emu-nt> <emu-t>class</emu-t> <emu-nt params="?Yield">BindingIdentifier</emu-nt> <emu-nt params="?Yield">ClassTail</emu-nt></emu-rhs>
|
||||
<emu-rhs constraints="+Default"><emu-nt params="?Yield" optional>DecoratorList</emu-nt> <emu-t>class</emu-t> <emu-nt params="?Yield">ClassTail</emu-nt></emu-rhs>
|
||||
</emu-production>
|
||||
<emu-production id="grammar-classexpression" name="ClassExpression" params="Yield, GeneratorParameter">
|
||||
<emu-rhs><emu-nt params="?Yield" optional>DecoratorList</emu-nt> <emu-t>class</emu-t> <emu-nt params="?Yield" optional>BindingIdentifier</emu-nt> <emu-nt params="?Yield, ?GeneratorParameter">ClassTail</emu-nt></emu-rhs>
|
||||
</emu-production>
|
||||
<emu-production id="grammar-classelement" name="ClassElement" params="Yield">
|
||||
<emu-rhs><emu-nt params="?Yield" optional>DecoratorList</emu-nt> <emu-nt params="?Yield">MethodDefinition</emu-nt></emu-rhs>
|
||||
<emu-rhs><emu-nt params="?Yield" optional>DecoratorList</emu-nt> <emu-t>static</emu-t> <emu-nt params="?Yield">MethodDefinition</emu-nt></emu-rhs>
|
||||
<emu-rhs><emu-t>;</emu-t></emu-rhs>
|
||||
</emu-production>
|
||||
<emu-production id="grammar-decoratorlist" name="DecoratorList" params="Yield">
|
||||
<emu-rhs><emu-nt params="?Yield" optional>DecoratorList</emu-nt> <emu-nt params="?Yield">Decorator</emu-nt></emu-rhs>
|
||||
</emu-production>
|
||||
<emu-production id="grammar-decorator" name="Decorator" params="Yield">
|
||||
<emu-rhs><emu-t>@</emu-t> <emu-nt params="Decorator, ?Yield">LeftHandSideExpression</emu-nt></emu-rhs>
|
||||
</emu-production>
|
||||
</emu-annex>
|
||||
|
||||
<emu-annex id="scripts-and-modules">
|
||||
<h1>Scripts and Modules</h1>
|
||||
<emu-production id="grammar-exportdeclaration" name="ExportDeclaration">
|
||||
<emu-rhs><emu-t>export</emu-t> <emu-t>*</emu-t> <emu-nt>FromClause</emu-nt> <emu-t>;</emu-t></emu-rhs>
|
||||
<emu-rhs><emu-t>export</emu-t> <emu-nt>ExportClause</emu-nt> <emu-nt>FromClause</emu-nt> <emu-t>;</emu-t></emu-rhs>
|
||||
<emu-rhs><emu-t>export</emu-t> <emu-nt>ExportClause</emu-nt> <emu-t>;</emu-t></emu-rhs>
|
||||
<emu-rhs><emu-t>export</emu-t> <emu-nt>VariableStatement</emu-nt></emu-rhs>
|
||||
<emu-rhs><emu-t>export</emu-t> <emu-gann>lookahead ≠ <emu-t>@</emu-t></emu-gann> <emu-nt>Declaration</emu-nt></emu-rhs>
|
||||
<emu-rhs><emu-t>export</emu-t> <emu-t>default</emu-t> <emu-nt params="Default">HoistableDeclaration</emu-nt></emu-rhs>
|
||||
<emu-rhs><emu-t>export</emu-t> <emu-t>default</emu-t> <emu-gann>lookahead ≠ <emu-t>@</emu-t></emu-gann> <emu-nt params="Default">ClassDeclaration</emu-nt></emu-rhs>
|
||||
<emu-rhs><emu-t>export</emu-t> <emu-t>default</emu-t> <emu-gann>lookahead ∉ { <emu-t>function</emu-t>, <emu-t>class</emu-t>, <emu-t>@</emu-t> }</emu-gann> <emu-nt>AssignmentExpression</emu-nt></emu-rhs>
|
||||
<emu-rhs><emu-nt>DecoratorList</emu-nt> <emu-t>export</emu-t> <emu-gann>lookahead ≠ <emu-t>@</emu-t></emu-gann> <emu-nt>ClassDeclaration</emu-nt></emu-rhs>
|
||||
<emu-rhs><emu-nt>DecoratorList</emu-nt> <emu-t>export</emu-t> <emu-t>default</emu-t> <emu-gann>lookahead ≠ <emu-t>@</emu-t></emu-gann> <emu-nt params="Default">ClassDeclaration</emu-nt></emu-rhs>
|
||||
</emu-production>
|
||||
</emu-annex>
|
||||
</emu-annex>
|
441
node_modules/reflect-metadata/spec/typescript-out.html
generated
vendored
Normal file
441
node_modules/reflect-metadata/spec/typescript-out.html
generated
vendored
Normal file
@ -0,0 +1,441 @@
|
||||
<!doctype html>
|
||||
<head><meta charset="utf8">
|
||||
<title>Decorators</title>
|
||||
<link rel="stylesheet" href="./css/elements.css">
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.4/styles/github.min.css">
|
||||
</head><body><emu-biblio href="./biblio.json"></emu-biblio>
|
||||
|
||||
<h1>Decorators Proposal - TypeScript</h1>
|
||||
<div><h2>Table of Contents</h2><ol class="toc"><li><a href="#introduction"><span class="secnum"></span> Introduction</a></li><li><a href="#proposal-terms"><span class="secnum">1</span> Terms</a><ol class="toc"><li><a href="#proposal-terms-decorator"><span class="secnum">1.1</span> Decorator</a></li><li><a href="#proposal-terms-classdecoratorfunction"><span class="secnum">1.2</span> Class Decorator Function</a></li><li><a href="#proposal-terms-propertydecoratorfunction"><span class="secnum">1.3</span> Property/Method Decorator Function</a></li><li><a href="#proposal-terms-parameterdecoratorfunction"><span class="secnum">1.4</span> Parameter Decorator Function</a></li><li><a href="#proposal-terms-decoratorfactory"><span class="secnum">1.5</span> Decorator Factory</a></li></ol></li><li><a href="#proposal-decoratortargets"><span class="secnum">2</span> Decorator Targets</a></li><li><a href="#proposal-decoratoreval"><span class="secnum">3</span> Decorator Evaluation and Application Order</a></li><li><a href="#reflect"><span class="secnum">4</span> Reflect API</a></li><li><a href="#transpile"><span class="secnum">5</span> Transformation</a><ol class="toc"><li><a href="#transpile-class"><span class="secnum">5.1</span> Class Declaration</a></li><li><a href="#transpile-exportclass"><span class="secnum">5.2</span> Class Declaration (Exported)</a></li><li><a href="#transpile-exportdefaultclass"><span class="secnum">5.3</span> Class Declaration (Default, Exported)</a></li><li><a href="#transpile-classmethod"><span class="secnum">5.4</span> Class Method Declaration</a></li><li><a href="#transpile-classaccessor"><span class="secnum">5.5</span> Class Accessor Declaration</a></li><li><a href="#transpile-classproperty"><span class="secnum">5.6</span> Class Property Declaration</a></li><li><a href="#transpile-classconstructorparameter"><span class="secnum">5.7</span> Class Constructor Parameter Declaration</a></li><li><a href="#transpile-classmethodparameter"><span class="secnum">5.8</span> Class Method Parameter Declaration</a></li><li><a href="#transpile-classaccessorparameter"><span class="secnum">5.9</span> Class Set Accessor Parameter Declaration</a></li></ol></li><li><a href="#grammar"><span class="secnum">A</span> Grammar</a><ol class="toc"><li><a href="#grammar-expressions"><span class="secnum">A.1</span> Expressions</a></li><li><a href="#functions-and-classes"><span class="secnum">A.2</span> Functions and Classes</a></li><li><a href="#scripts-and-modules"><span class="secnum">A.3</span> Scripts and Modules</a></li></ol></li><li><a href="#typescript"><span class="secnum">B</span> TypeScript</a><ol class="toc"><li><a href="#typescript-definitions"><span class="secnum">B.1</span> TypeScript Definitions</a></li></ol></li></ol></div><emu-intro id="introduction">
|
||||
<h1><span class="secnum"></span>Introduction</h1>
|
||||
<p>Proposal to add Decorators to TypeScript.</p>
|
||||
<p>For the ECMAScript specific proposal, see <a href="index.html">http://rbuckton.github.io/reflectdecorators/index.html</a></p>
|
||||
</emu-intro>
|
||||
|
||||
<emu-clause id="proposal-terms">
|
||||
<h1><span class="secnum">1</span>Terms</h1>
|
||||
<emu-clause id="proposal-terms-decorator">
|
||||
<h1><span class="secnum">1.1</span>Decorator</h1>
|
||||
<emu-note><span class="note">Note</span>This section is non-normative.</emu-note>
|
||||
<p>A <em>decorator</em> is an expression that is evaluated after a class has been defined, that can be used to annotate or modify the class in some fashion. This expression must evaluate to a <code>function</code>, which is executed by the runtime to apply the decoration.</p>
|
||||
<pre><code class="typescript hljs">@decoratorExpression
|
||||
<span class="hljs-keyword">class</span> C {
|
||||
}
|
||||
</code></pre>
|
||||
</emu-clause>
|
||||
<emu-clause id="proposal-terms-classdecoratorfunction">
|
||||
<h1><span class="secnum">1.2</span>Class Decorator Function</h1>
|
||||
<emu-note><span class="note">Note</span>This section is non-normative.</emu-note>
|
||||
<p>A <em>class decorator function</em> is a function that accepts a constructor function as its argument, and returns either <code>undefined</code>, the provided constructor function, or a new constructor function. Returning <code>undefined</code> is equivalent to returning the provided constructor function.</p>
|
||||
<pre><code class="typescript hljs"><span class="hljs-comment">// A class decorator function</span>
|
||||
<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">dec</span><span class="hljs-params">(target)</span> </span>{
|
||||
<span class="hljs-comment">// modify, annotate, or replace target...</span>
|
||||
}
|
||||
</code></pre>
|
||||
</emu-clause>
|
||||
<emu-clause id="proposal-terms-propertydecoratorfunction">
|
||||
<h1><span class="secnum">1.3</span>Property/Method Decorator Function</h1>
|
||||
<emu-note><span class="note">Note</span>This section is non-normative.</emu-note>
|
||||
<p>A <em>property decorator function</em> is a function that accepts three arguments: The object that owns the property, the key for the property (a <code>string</code> or a <code>symbol</code>), and optionally the property descriptor of the property. The function must return either <code>undefined</code>, the provided property descriptor, or a new property descriptor. Returning <code>undefined</code> is equivalent to returning the provided property descriptor.</p>
|
||||
<pre><code class="typescript hljs"><span class="hljs-comment">// A property (or method/accessor) decorator function</span>
|
||||
<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">dec</span><span class="hljs-params">(target, key, descriptor)</span> </span>{
|
||||
<span class="hljs-comment">// annotate the target and key; or modify or replace the descriptor...</span>
|
||||
}
|
||||
</code></pre>
|
||||
</emu-clause>
|
||||
<emu-clause id="proposal-terms-parameterdecoratorfunction">
|
||||
<h1><span class="secnum">1.4</span>Parameter Decorator Function</h1>
|
||||
<emu-note><span class="note">Note</span>This section is non-normative.</emu-note>
|
||||
<p>A <em>parameter decorator function</em> is a function that accepts three arguments: The function that contains the decorated parameter, the property key of the member (or <code>undefined</code> for a parameter of the constructor), and the ordinal index of the parameter. The return value of this decorator is ignored.</p>
|
||||
<pre><code class="typescript hljs">
|
||||
<span class="hljs-comment">// A parameter decorator</span>
|
||||
<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">dec</span><span class="hljs-params">(target, paramIndex)</span> </span>{
|
||||
<span class="hljs-comment">// annotate the target and index</span>
|
||||
}
|
||||
</code></pre>
|
||||
</emu-clause>
|
||||
<emu-clause id="proposal-terms-decoratorfactory">
|
||||
<h1><span class="secnum">1.5</span>Decorator Factory</h1>
|
||||
<emu-note><span class="note">Note</span>This section is non-normative.</emu-note>
|
||||
<p>A <em>decorator factory</em> is a function that can accept any number of arguments, and must return one of the above types of decorator function.</p>
|
||||
<pre><code class="typescript hljs"><span class="hljs-comment">// a class decorator factory function</span>
|
||||
<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">dec</span><span class="hljs-params">(x, y)</span> </span>{
|
||||
<span class="hljs-comment">// the class decorator function</span>
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-params">(target)</span> </span>{
|
||||
<span class="hljs-comment">// modify, annotate, or replace target...</span>
|
||||
}
|
||||
}
|
||||
</code></pre>
|
||||
</emu-clause>
|
||||
</emu-clause>
|
||||
<emu-clause id="proposal-decoratortargets">
|
||||
<h1><span class="secnum">2</span>Decorator Targets</h1>
|
||||
<emu-note><span class="note">Note</span>This section is non-normative.</emu-note>
|
||||
<p>A <em>decorator</em> <strong>can</strong> be legally applied to any of the following:</p>
|
||||
<ul>
|
||||
<li>A class declaration</li>
|
||||
<li>A class property initializer (static or prototype)</li>
|
||||
<li>A class method declaration (static or prototype)</li>
|
||||
<li>A class get or set accessor declaration (static or prototype)</li>
|
||||
<li>A parameter of a class constructor</li>
|
||||
<li>A parameter of a class method (static or prototype)</li>
|
||||
<li>A parameter of a class get or set accessor (static or prototype)</li>
|
||||
</ul>
|
||||
<p>Please note that a <em>decorator</em> currently <strong>cannot</strong> be legally applied to any of the following:</p>
|
||||
<ul>
|
||||
<li>A class constructor - This is to reduce ambiguity between where you can apply a decorator (on the class or on its constructor) and which of the above decorator function forms is called.</li>
|
||||
<li>A function declaration - Decorators on a function declaration would introduce a TDZ (Temporal Dead Zone), which would make the function unreachable until its declaration is executed. This could cause confusion as an undecorated function declaration is hoisted and can be used in a statement preceeding the declaration.</li>
|
||||
<li>A function expression - This is to reduce confusion and maintain parity with disallowing decorators on a function declaration.</li>
|
||||
<li>An arrow function - This is to reduce confusion and maintain parity with disallowing decorators on a function expression.</li>
|
||||
</ul>
|
||||
<p>This list may change in the future.</p>
|
||||
</emu-clause>
|
||||
<emu-clause id="proposal-decoratoreval">
|
||||
<h1><span class="secnum">3</span>Decorator Evaluation and Application Order</h1>
|
||||
<emu-note><span class="note">Note</span>This section is non-normative.</emu-note>
|
||||
<p>Decorators are <em>evaluated</em> in the order they appear preceeding their target declaration, to preserve side-effects due to evaluation order. Decorators are <em>applied</em> to their target declaration in reverse order, starting with the decorator closest to the declaration. This behavior is specified to preserve the expected behavior of decorators without a declarative syntax.</p>
|
||||
<pre><code class="typescript hljs">@F
|
||||
@G
|
||||
<span class="hljs-keyword">class</span> C {
|
||||
}
|
||||
</code></pre>
|
||||
<p>For example, the above listing could be approximately written without decorators in the following fashion:</p>
|
||||
<pre><code class="typescript hljs">C = F(G(C))</code></pre>
|
||||
<p>In the above example, the expression <code>F</code> is evaluated first, followed by the expression <code>G</code>. <code>G</code> is then called with the constructor function as its argument, followed by calling <code>F</code> with the result. The actual process of applying decorators is more complex than the above example however, though you may still imperatively apply decorators with a reflection API.</p>
|
||||
<p>If a class declaration has decorators on both the class and any of its members or parameters, the decorators are applied using the following pseudocode:</p>
|
||||
<pre>for each member M of class C
|
||||
if M is an accessor then
|
||||
let accessor = first accessor (get or set, in declaration order) of M
|
||||
let memberDecorators = decorators of accessor
|
||||
for each parameter of accessor
|
||||
let paramDecorators = decorators of parameter
|
||||
let paramIndex = ordinal index of parameter
|
||||
Reflect.decorate(paramDecorators, accessor, paramIndex)
|
||||
next parameter
|
||||
|
||||
let accessor = second accessor (get or set, in declaration order) of M
|
||||
if accessor then
|
||||
let memberDecorators = memberDecorators + decorators of accessor
|
||||
for each parameter of accessor
|
||||
let paramDecorators = decorators of parameter
|
||||
let paramIndex = ordinal index of parameter
|
||||
Reflect.decorate(paramDecorators, accessor, paramIndex)
|
||||
next parameter
|
||||
end if
|
||||
else if M is a method
|
||||
let memberDecorators = decorators of M
|
||||
for each parameter of M
|
||||
let paramDecorators = decorators of parameter
|
||||
let paramIndex = ordinal index of parameter
|
||||
Reflect.decorate(paramDecorators, M, paramIndex)
|
||||
next parameter
|
||||
else
|
||||
let memberDecorators = decorators of M
|
||||
end if
|
||||
|
||||
let name = name of M
|
||||
let target = C.prototype if M is on the prototype; otherwise, C if M is static
|
||||
Reflect.decorate(memberDecorators, C, name)
|
||||
next member
|
||||
|
||||
for each parameter of C
|
||||
let paramDecorators = decorators of parameter
|
||||
let paramIndex = ordinal index of parameter
|
||||
Reflect.decorate(paramDecorators, C, paramIndex)
|
||||
next parameter
|
||||
|
||||
let classDecorators = decorators of C
|
||||
let C = Reflect.decorate(classDecorators, C)
|
||||
</pre>
|
||||
</emu-clause>
|
||||
|
||||
<emu-clause id="reflect">
|
||||
<h1><span class="secnum">4</span>Reflect API</h1>
|
||||
<emu-note><span class="note">Note</span>This section is non-normative.</emu-note>
|
||||
<p>In addition to a declarative approach to defining decorators, it is necessary to also include an imperative API capable of applying decorators, as well as defining, reflecting over, and removing decorator metadata from an object, property, or parameter.</p>
|
||||
<p>A shim for this API can be found here: <a href="https://github.com/rbuckton/ReflectDecorators">https://github.com/rbuckton/ReflectDecorators</a></p>
|
||||
<pre><code class="typescript hljs">Reflect.decorate(decorators, target, propertyKey?, descriptor?)</code></pre>
|
||||
</emu-clause>
|
||||
|
||||
<emu-clause id="transpile">
|
||||
<h1><span class="secnum">5</span>Transformation</h1>
|
||||
<p>The following are examples of how decorators can be desugared to ES6 (through a transpiler such as TypeScript). These examples levarage an imperative reflection API.</p>
|
||||
<emu-clause id="transpile-class">
|
||||
<h1><span class="secnum">5.1</span>Class Declaration</h1>
|
||||
<h2>Syntax</h2>
|
||||
<pre><code class="typescript hljs">@F(<span class="hljs-string">"color"</span>)
|
||||
@G
|
||||
<span class="hljs-keyword">class</span> C {
|
||||
}
|
||||
</code></pre>
|
||||
<h2>ES6 Transformation</h2>
|
||||
<pre><code class="javascript hljs"><span class="hljs-keyword">let</span> C = <span class="hljs-keyword">class</span> {
|
||||
}
|
||||
<span class="hljs-built_in">Object</span>.defineProperty(C, <span class="hljs-string">"name"</span>, { value: <span class="hljs-string">"C"</span>, configurable: <span class="hljs-literal">true</span> });
|
||||
C = __decorate([F(<span class="hljs-string">"color"</span>), G], C);
|
||||
</code></pre>
|
||||
</emu-clause>
|
||||
|
||||
<emu-clause id="transpile-exportclass">
|
||||
<h1><span class="secnum">5.2</span>Class Declaration (Exported)</h1>
|
||||
<h2>Syntax</h2>
|
||||
<pre><code class="typescript hljs">@F(<span class="hljs-string">"color"</span>)
|
||||
@G
|
||||
<span class="hljs-keyword">export</span> <span class="hljs-keyword">class</span> C {
|
||||
}
|
||||
</code></pre>
|
||||
<h2>ES6 Transformation</h2>
|
||||
<pre><code class="javascript hljs">export <span class="hljs-keyword">let</span> C = <span class="hljs-keyword">class</span> {
|
||||
}
|
||||
<span class="hljs-built_in">Object</span>.defineProperty(C, <span class="hljs-string">"name"</span>, { value: <span class="hljs-string">"C"</span>, configurable: <span class="hljs-literal">true</span> });
|
||||
C = __decorate([F(<span class="hljs-string">"color"</span>), G], C);
|
||||
</code></pre>
|
||||
</emu-clause>
|
||||
|
||||
<emu-clause id="transpile-exportdefaultclass">
|
||||
<h1><span class="secnum">5.3</span>Class Declaration (Default, Exported)</h1>
|
||||
<h2>Syntax</h2>
|
||||
<pre><code class="typescript hljs">@F(<span class="hljs-string">"color"</span>)
|
||||
@G
|
||||
<span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> <span class="hljs-keyword">class</span> C {
|
||||
}
|
||||
</code></pre>
|
||||
<h2>ES6 Transformation</h2>
|
||||
<pre><code class="javascript hljs"><span class="hljs-keyword">let</span> C = <span class="hljs-keyword">class</span> {
|
||||
}
|
||||
<span class="hljs-built_in">Object</span>.defineProperty(C, <span class="hljs-string">"name"</span>, { value: <span class="hljs-string">"C"</span>, configurable: <span class="hljs-literal">true</span> });
|
||||
C = __decorate([F(<span class="hljs-string">"color"</span>), G], C);
|
||||
export <span class="hljs-keyword">default</span> C;
|
||||
</code></pre>
|
||||
</emu-clause>
|
||||
|
||||
<emu-clause id="transpile-classmethod">
|
||||
<h1><span class="secnum">5.4</span>Class Method Declaration</h1>
|
||||
<h2>Syntax</h2>
|
||||
<pre><code class="typescript hljs"><span class="hljs-keyword">class</span> C {
|
||||
@F(<span class="hljs-string">"color"</span>)
|
||||
@G
|
||||
method() { }
|
||||
}
|
||||
</code></pre>
|
||||
<h2>ES6 Transformation</h2>
|
||||
<pre><code class="javascript hljs"><span class="hljs-keyword">class</span> C {
|
||||
method() { }
|
||||
}
|
||||
<span class="hljs-built_in">Object</span>.defineProperty(C.prototype, <span class="hljs-string">"method"</span>,
|
||||
__decorate([F(<span class="hljs-string">"color"</span>), G], C.prototype, <span class="hljs-string">"method"</span>, <span class="hljs-built_in">Object</span>.getOwnPropertyDescriptor(C.prototype, <span class="hljs-string">"method"</span>)));
|
||||
</code></pre>
|
||||
</emu-clause>
|
||||
|
||||
<emu-clause id="transpile-classaccessor">
|
||||
<h1><span class="secnum">5.5</span>Class Accessor Declaration</h1>
|
||||
<h2>Syntax</h2>
|
||||
<pre><code class="typescript hljs"><span class="hljs-keyword">class</span> C {
|
||||
@F(<span class="hljs-string">"color"</span>)
|
||||
@G
|
||||
<span class="hljs-keyword">get</span> accessor() { }
|
||||
<span class="hljs-keyword">set</span> accessor(value) { }
|
||||
}
|
||||
</code></pre>
|
||||
<h2>ES6 Transformation</h2>
|
||||
<pre><code class="javascript hljs"><span class="hljs-keyword">class</span> C {
|
||||
get accessor() { }
|
||||
set accessor(value) { }
|
||||
}
|
||||
<span class="hljs-built_in">Object</span>.defineProperty(C.prototype, <span class="hljs-string">"accessor"</span>,
|
||||
__decorate([F(<span class="hljs-string">"color"</span>), G], C.prototype, <span class="hljs-string">"accessor"</span>, <span class="hljs-built_in">Object</span>.getOwnPropertyDescriptor(C.prototype, <span class="hljs-string">"accessor"</span>)));
|
||||
</code></pre>
|
||||
</emu-clause>
|
||||
|
||||
<emu-clause id="transpile-classproperty">
|
||||
<h1><span class="secnum">5.6</span>Class Property Declaration</h1>
|
||||
<h2>Syntax</h2>
|
||||
<pre><code class="typescript hljs"><span class="hljs-keyword">class</span> C {
|
||||
@F(<span class="hljs-string">"color"</span>)
|
||||
@G
|
||||
property = <span class="hljs-number">1</span>;
|
||||
}
|
||||
</code></pre>
|
||||
<h2>ES6 Transformation</h2>
|
||||
<pre><code class="javascript hljs"><span class="hljs-keyword">class</span> C {
|
||||
constructor() {
|
||||
<span class="hljs-keyword">this</span>.property = <span class="hljs-number">1</span>;
|
||||
}
|
||||
}
|
||||
__decorate([F(<span class="hljs-string">"color"</span>), G], C.prototype, <span class="hljs-string">"property"</span>);
|
||||
</code></pre>
|
||||
</emu-clause>
|
||||
|
||||
<emu-clause id="transpile-classconstructorparameter">
|
||||
<h1><span class="secnum">5.7</span>Class Constructor Parameter Declaration</h1>
|
||||
<h2>Syntax</h2>
|
||||
<pre><code class="typescript hljs"><span class="hljs-keyword">class</span> C {
|
||||
<span class="hljs-constructor"><span class="hljs-keyword">constructor</span>(@F("color") @G p) </span>{ }
|
||||
}
|
||||
</code></pre>
|
||||
<h2>ES6 Transformation</h2>
|
||||
<pre><code class="javascript hljs"><span class="hljs-keyword">class</span> C {
|
||||
constructor(p) { }
|
||||
}
|
||||
__decorate([F(<span class="hljs-string">"color"</span>), G], C, <span class="hljs-keyword">void</span> <span class="hljs-number">0</span>, <span class="hljs-number">0</span>);
|
||||
</code></pre>
|
||||
</emu-clause>
|
||||
|
||||
<emu-clause id="transpile-classmethodparameter">
|
||||
<h1><span class="secnum">5.8</span>Class Method Parameter Declaration</h1>
|
||||
<h2>Syntax</h2>
|
||||
<pre><code class="typescript hljs"><span class="hljs-keyword">class</span> C {
|
||||
method(@F(<span class="hljs-string">"color"</span>) @G p) { }
|
||||
}
|
||||
</code></pre>
|
||||
<h2>ES6 Transformation</h2>
|
||||
<pre><code class="javascript hljs"><span class="hljs-keyword">class</span> C {
|
||||
method(p) { }
|
||||
}
|
||||
__decorate([F(<span class="hljs-string">"color"</span>), G], C.prototype, <span class="hljs-string">"method"</span>, <span class="hljs-number">0</span>);
|
||||
</code></pre>
|
||||
</emu-clause>
|
||||
|
||||
<emu-clause id="transpile-classaccessorparameter">
|
||||
<h1><span class="secnum">5.9</span>Class Set Accessor Parameter Declaration</h1>
|
||||
<h2>Syntax</h2>
|
||||
<pre><code class="typescript hljs"><span class="hljs-keyword">class</span> C {
|
||||
<span class="hljs-keyword">set</span> accessor(@F(<span class="hljs-string">"color"</span>) @G p) { }
|
||||
}
|
||||
</code></pre>
|
||||
<h2>ES6 Transformation</h2>
|
||||
<pre><code class="javascript hljs"><span class="hljs-keyword">class</span> C {
|
||||
set accessor(p) { }
|
||||
}
|
||||
__decorate([F(<span class="hljs-string">"color"</span>), G], C.prototype, <span class="hljs-string">"accessor"</span>, <span class="hljs-number">0</span>);
|
||||
</code></pre>
|
||||
</emu-clause>
|
||||
|
||||
</emu-clause>
|
||||
|
||||
<emu-annex id="grammar">
|
||||
<h1><span class="secnum">A</span>Grammar</h1>
|
||||
<emu-annex id="grammar-expressions">
|
||||
<h1><span class="secnum">A.1</span>Expressions</h1>
|
||||
<emu-production id="grammar-memberexpression" name="MemberExpression" params="Yield, Decorator">
|
||||
<emu-nt>MemberExpression<emu-mods> [Yield, Decorator]</emu-mods><emu-mods></emu-mods></emu-nt><emu-geq>:</emu-geq><emu-rhs><emu-nt params="?Yield">PrimaryExpression<emu-mods> [?Yield]</emu-mods></emu-nt></emu-rhs>
|
||||
<emu-rhs constraints="~Decorator"><emu-constraints>[~Decorator]</emu-constraints><emu-nt params="?Yield, ?Decorator">MemberExpression<emu-mods> [?Yield, ?Decorator]</emu-mods></emu-nt><emu-t>[</emu-t><emu-nt params="In, ?Yield">Expression<emu-mods> [In, ?Yield]</emu-mods></emu-nt><emu-t>]</emu-t></emu-rhs>
|
||||
<emu-rhs><emu-nt params="?Yield, ?Decorator">MemberExpression<emu-mods> [?Yield, ?Decorator]</emu-mods></emu-nt><emu-t>.</emu-t><emu-nt>IdentifierName<emu-mods></emu-mods></emu-nt></emu-rhs>
|
||||
<emu-rhs><emu-nt params="?Yield, ?Decorator">MemberExpression<emu-mods> [?Yield, ?Decorator]</emu-mods></emu-nt><emu-nt params="?Yield">TemplateLiteral<emu-mods> [?Yield]</emu-mods></emu-nt></emu-rhs>
|
||||
<emu-rhs><emu-nt params="?Yield, ?Decorator">SuperProperty<emu-mods> [?Yield, ?Decorator]</emu-mods></emu-nt></emu-rhs>
|
||||
<emu-rhs><emu-nt>MetaProperty<emu-mods></emu-mods></emu-nt></emu-rhs>
|
||||
<emu-rhs><emu-t>new</emu-t><emu-nt params="?Yield, ?Decorator">MemberExpression<emu-mods> [?Yield, ?Decorator]</emu-mods></emu-nt><emu-nt params="?Yield">Arguments<emu-mods> [?Yield]</emu-mods></emu-nt></emu-rhs>
|
||||
</emu-production>
|
||||
<emu-production id="grammar-superproperty" name="SuperProperty" params="Yield, Decorator">
|
||||
<emu-nt>SuperProperty<emu-mods> [Yield, Decorator]</emu-mods><emu-mods></emu-mods></emu-nt><emu-geq>:</emu-geq><emu-rhs constraints="~Decorator"><emu-constraints>[~Decorator]</emu-constraints><emu-t>super</emu-t><emu-t>[</emu-t><emu-nt params="In, ?Yield">Expression<emu-mods> [In, ?Yield]</emu-mods></emu-nt><emu-t>]</emu-t></emu-rhs>
|
||||
</emu-production>
|
||||
<emu-production id="grammar-newexpression" name="NewExpression" params="Yield, Decorator">
|
||||
<emu-nt>NewExpression<emu-mods> [Yield, Decorator]</emu-mods><emu-mods></emu-mods></emu-nt><emu-geq>:</emu-geq><emu-rhs><emu-nt params="?Yield, ?Decorator">MemberExpression<emu-mods> [?Yield, ?Decorator]</emu-mods></emu-nt></emu-rhs>
|
||||
<emu-rhs><emu-t>new</emu-t><emu-nt params="?Yield, ?Decorator">NewExpression<emu-mods> [?Yield, ?Decorator]</emu-mods></emu-nt></emu-rhs>
|
||||
</emu-production>
|
||||
<emu-production id="grammar-callexpression" name="CallExpression" params="Yield, Decorator">
|
||||
<emu-nt>CallExpression<emu-mods> [Yield, Decorator]</emu-mods><emu-mods></emu-mods></emu-nt><emu-geq>:</emu-geq><emu-rhs><emu-nt params="?Yield, ?Decorator">MemberExpression<emu-mods> [?Yield, ?Decorator]</emu-mods></emu-nt><emu-nt params="?Yield">Arguments<emu-mods> [?Yield]</emu-mods></emu-nt></emu-rhs>
|
||||
<emu-rhs><emu-nt params="?Yield">SuperCall<emu-mods> [?Yield]</emu-mods></emu-nt></emu-rhs>
|
||||
<emu-rhs><emu-nt params="?Yield, ?Decorator">CallExpression<emu-mods> [?Yield, ?Decorator]</emu-mods></emu-nt><emu-nt params="?Yield">Arguments<emu-mods> [?Yield]</emu-mods></emu-nt></emu-rhs>
|
||||
<emu-rhs constraints="~Decorator"><emu-constraints>[~Decorator]</emu-constraints><emu-nt params="?Yield">CallExpression<emu-mods> [?Yield]</emu-mods></emu-nt><emu-t>[</emu-t><emu-nt params="In, ?Yield">Expression<emu-mods> [In, ?Yield]</emu-mods></emu-nt><emu-t>]</emu-t></emu-rhs>
|
||||
<emu-rhs><emu-nt params="?Yield, ?Decorator">CallExpression<emu-mods> [?Yield, ?Decorator]</emu-mods></emu-nt><emu-t>.</emu-t><emu-nt>IdentifierName<emu-mods></emu-mods></emu-nt></emu-rhs>
|
||||
<emu-rhs><emu-nt params="?Yield, ?Decorator">CallExpression<emu-mods> [?Yield, ?Decorator]</emu-mods></emu-nt><emu-nt params="?Yield">TemplateLiteral<emu-mods> [?Yield]</emu-mods></emu-nt></emu-rhs>
|
||||
</emu-production>
|
||||
<emu-production id="grammar-lefthandsideexpression" name="LeftHandSideExpression" params="Yield, Decorator">
|
||||
<emu-nt>LeftHandSideExpression<emu-mods> [Yield, Decorator]</emu-mods><emu-mods></emu-mods></emu-nt><emu-geq>:</emu-geq><emu-rhs><emu-nt params="?Yield, ?Decorator">NewExpression<emu-mods> [?Yield, ?Decorator]</emu-mods></emu-nt></emu-rhs>
|
||||
<emu-rhs><emu-nt params="?Yield, ?Decorator">CallExpression<emu-mods> [?Yield, ?Decorator]</emu-mods></emu-nt></emu-rhs>
|
||||
</emu-production>
|
||||
</emu-annex>
|
||||
|
||||
<emu-annex id="functions-and-classes">
|
||||
<h1><span class="secnum">A.2</span>Functions and Classes</h1>
|
||||
<emu-production id="grammar-strictformalparameters" name="StrictFormalParameters" params="Yield, GeneratorParameter, ClassParameter">
|
||||
<emu-nt>StrictFormalParameters<emu-mods> [Yield, GeneratorParameter, ClassParameter]</emu-mods><emu-mods></emu-mods></emu-nt><emu-geq>:</emu-geq><emu-rhs><emu-nt params="?Yield, ?GeneratorParameter, ?ClassParameter">FormalParameters<emu-mods> [?Yield, ?GeneratorParameter, ?ClassParameter]</emu-mods></emu-nt></emu-rhs>
|
||||
</emu-production>
|
||||
<emu-production id="grammar-formalparameters" name="FormalParameters" params="Yield, GeneratorParameter, ClassParameter">
|
||||
<emu-nt>FormalParameters<emu-mods> [Yield, GeneratorParameter, ClassParameter]</emu-mods><emu-mods></emu-mods></emu-nt><emu-geq>:</emu-geq><emu-rhs><emu-prose>[empty]</emu-prose></emu-rhs>
|
||||
<emu-rhs><emu-nt params="?Yield, ?GeneratorParameter, ?ClassParameter">FormalParameterList<emu-mods> [?Yield, ?GeneratorParameter, ?ClassParameter]</emu-mods></emu-nt></emu-rhs>
|
||||
</emu-production>
|
||||
<emu-production id="grammar-formalparameterlist" name="FormalParameterList" params="Yield, GeneratorParameter, ClassParameter">
|
||||
<emu-nt>FormalParameterList<emu-mods> [Yield, GeneratorParameter, ClassParameter]</emu-mods><emu-mods></emu-mods></emu-nt><emu-geq>:</emu-geq><emu-rhs><emu-nt params="?Yield, ?ClassParameter">FunctionRestParameter<emu-mods> [?Yield, ?ClassParameter]</emu-mods></emu-nt></emu-rhs>
|
||||
<emu-rhs><emu-nt params="?Yield, ?GeneratorParameter, ?ClassParameter">FormalsList<emu-mods> [?Yield, ?GeneratorParameter, ?ClassParameter]</emu-mods></emu-nt></emu-rhs>
|
||||
<emu-rhs><emu-nt params="?Yield, ?GeneratorParameter, ?ClassParameter">FormalsList<emu-mods> [?Yield, ?GeneratorParameter, ?ClassParameter]</emu-mods></emu-nt><emu-t>,</emu-t><emu-nt params="?Yield, ?ClassParameter">FunctionRestParameter<emu-mods> [?Yield, ?ClassParameter]</emu-mods></emu-nt></emu-rhs>
|
||||
</emu-production>
|
||||
<emu-production id="grammar-formalslist" name="FormalsList" params="Yield, GeneratorParameter, ClassParameter">
|
||||
<emu-nt>FormalsList<emu-mods> [Yield, GeneratorParameter, ClassParameter]</emu-mods><emu-mods></emu-mods></emu-nt><emu-geq>:</emu-geq><emu-rhs><emu-nt params="?Yield, ?GeneratorParameter, ?ClassParameter">FormalParameter<emu-mods> [?Yield, ?GeneratorParameter, ?ClassParameter]</emu-mods></emu-nt></emu-rhs>
|
||||
<emu-rhs><emu-nt params="?Yield, ?GeneratorParameter, ?ClassParameter">FormalsList<emu-mods> [?Yield, ?GeneratorParameter, ?ClassParameter]</emu-mods></emu-nt><emu-t>,</emu-t><emu-nt params="?Yield, ?GeneratorParameter, ?ClassParameter">FormalParameter<emu-mods> [?Yield, ?GeneratorParameter, ?ClassParameter]</emu-mods></emu-nt></emu-rhs>
|
||||
</emu-production>
|
||||
<emu-production id="grammar-functionrestparameter" name="FunctionRestParameter" params="Yield, ClassParameter">
|
||||
<emu-nt>FunctionRestParameter<emu-mods> [Yield, ClassParameter]</emu-mods><emu-mods></emu-mods></emu-nt><emu-geq>:</emu-geq><emu-rhs><emu-nt params="?Yield">BindingRestElement<emu-mods> [?Yield]</emu-mods></emu-nt></emu-rhs>
|
||||
<emu-rhs constraints="+ClassParameter"><emu-constraints>[+ClassParameter]</emu-constraints><emu-nt>DecoratorList<emu-mods></emu-mods></emu-nt><emu-nt params="?Yield">BindingRestElement<emu-mods> [?Yield]</emu-mods></emu-nt></emu-rhs>
|
||||
</emu-production>
|
||||
<emu-production id="grammar-formalparameter" name="FormalParameter" params="Yield, GeneratorParameter, ClassParameter">
|
||||
<emu-nt>FormalParameter<emu-mods> [Yield, GeneratorParameter, ClassParameter]</emu-mods><emu-mods></emu-mods></emu-nt><emu-geq>:</emu-geq><emu-rhs><emu-nt params="?Yield, ?GeneratorParameter">BindingElement<emu-mods> [?Yield, ?GeneratorParameter]</emu-mods></emu-nt></emu-rhs>
|
||||
<emu-rhs constraints="+ClassParameter"><emu-constraints>[+ClassParameter]</emu-constraints><emu-nt>DecoratorList<emu-mods></emu-mods></emu-nt><emu-nt params="?Yield, ?GeneratorParameter">BindingElement<emu-mods> [?Yield, ?GeneratorParameter]</emu-mods></emu-nt></emu-rhs>
|
||||
</emu-production>
|
||||
<emu-production id="grammar-methoddefinition" name="MethodDefinition" params="Yield, ClassParameter">
|
||||
<emu-nt>MethodDefinition<emu-mods> [Yield, ClassParameter]</emu-mods><emu-mods></emu-mods></emu-nt><emu-geq>:</emu-geq><emu-rhs><emu-nt params="?Yield">PropertyName<emu-mods> [?Yield]</emu-mods></emu-nt><emu-t>(</emu-t><emu-nt params="?ClassParameter">StrictFormalParameters<emu-mods> [?ClassParameter]</emu-mods></emu-nt><emu-t>)</emu-t><emu-t>{</emu-t><emu-nt>FunctionBody<emu-mods></emu-mods></emu-nt><emu-t>}</emu-t></emu-rhs>
|
||||
<emu-rhs><emu-nt params="?Yield, ?ClassParameter">GeneratorMethod<emu-mods> [?Yield, ?ClassParameter]</emu-mods></emu-nt></emu-rhs>
|
||||
<emu-rhs><emu-t>get</emu-t><emu-nt params="?Yield">PropertyName<emu-mods> [?Yield]</emu-mods></emu-nt><emu-t>(</emu-t><emu-t>)</emu-t><emu-t>{</emu-t><emu-nt>FunctionBody<emu-mods></emu-mods></emu-nt><emu-t>}</emu-t></emu-rhs>
|
||||
<emu-rhs><emu-t>set</emu-t><emu-nt params="?Yield">PropertyName<emu-mods> [?Yield]</emu-mods></emu-nt><emu-t>(</emu-t><emu-nt params="?ClassParameter">PropertySetParameterList<emu-mods> [?ClassParameter]</emu-mods></emu-nt><emu-t>)</emu-t><emu-t>{</emu-t><emu-nt>FunctionBody<emu-mods></emu-mods></emu-nt><emu-t>}</emu-t></emu-rhs>
|
||||
</emu-production>
|
||||
<emu-production id="grammar-generatormethod" name="GeneratorMethod" params="Yield, ClassParameter">
|
||||
<emu-nt>GeneratorMethod<emu-mods> [Yield, ClassParameter]</emu-mods><emu-mods></emu-mods></emu-nt><emu-geq>:</emu-geq><emu-rhs><emu-t>*</emu-t><emu-nt params="?Yield">PropertyName<emu-mods> [?Yield]</emu-mods></emu-nt><emu-t>(</emu-t><emu-nt params="Yield, GeneratorParameter, ?ClassParameter">StrictFormalParameters<emu-mods> [Yield, GeneratorParameter, ?ClassParameter]</emu-mods></emu-nt><emu-t>)</emu-t><emu-t>{</emu-t><emu-nt>GeneratorBody<emu-mods></emu-mods></emu-nt><emu-t>}</emu-t></emu-rhs>
|
||||
</emu-production>
|
||||
<emu-production id="grammar-classdeclaration" name="ClassDeclaration" params="Yield, Default">
|
||||
<emu-nt>ClassDeclaration<emu-mods> [Yield, Default]</emu-mods><emu-mods></emu-mods></emu-nt><emu-geq>:</emu-geq><emu-rhs><emu-nt params="?Yield" optional="">DecoratorList<emu-mods> [?Yield] opt</emu-mods></emu-nt><emu-t>class</emu-t><emu-nt params="?Yield">BindingIdentifier<emu-mods> [?Yield]</emu-mods></emu-nt><emu-nt params="?Yield">ClassTail<emu-mods> [?Yield]</emu-mods></emu-nt></emu-rhs>
|
||||
<emu-rhs constraints="+Default"><emu-constraints>[+Default]</emu-constraints><emu-nt params="?Yield" optional="">DecoratorList<emu-mods> [?Yield] opt</emu-mods></emu-nt><emu-t>class</emu-t><emu-nt params="?Yield">ClassTail<emu-mods> [?Yield]</emu-mods></emu-nt></emu-rhs>
|
||||
</emu-production>
|
||||
<emu-production id="grammar-classexpression" name="ClassExpression" params="Yield, GeneratorParameter">
|
||||
<emu-nt>ClassExpression<emu-mods> [Yield, GeneratorParameter]</emu-mods><emu-mods></emu-mods></emu-nt><emu-geq>:</emu-geq><emu-rhs><emu-nt params="?Yield" optional="">DecoratorList<emu-mods> [?Yield] opt</emu-mods></emu-nt><emu-t>class</emu-t><emu-nt params="?Yield" optional="">BindingIdentifier<emu-mods> [?Yield] opt</emu-mods></emu-nt><emu-nt params="?Yield, ?GeneratorParameter">ClassTail<emu-mods> [?Yield, ?GeneratorParameter]</emu-mods></emu-nt></emu-rhs>
|
||||
</emu-production>
|
||||
<emu-production id="grammar-classelement" name="ClassElement" params="Yield">
|
||||
<emu-nt>ClassElement<emu-mods> [Yield]</emu-mods><emu-mods></emu-mods></emu-nt><emu-geq>:</emu-geq><emu-rhs><emu-nt params="?Yield" optional="">DecoratorList<emu-mods> [?Yield] opt</emu-mods></emu-nt><emu-nt params="ClassParameter, ?Yield">MethodDefinition<emu-mods> [ClassParameter, ?Yield]</emu-mods></emu-nt></emu-rhs>
|
||||
<emu-rhs><emu-nt params="?Yield" optional="">DecoratorList<emu-mods> [?Yield] opt</emu-mods></emu-nt><emu-t>static</emu-t><emu-nt params="ClassParameter, ?Yield">MethodDefinition<emu-mods> [ClassParameter, ?Yield]</emu-mods></emu-nt></emu-rhs>
|
||||
<emu-rhs><emu-nt params="?Yield" optional="">DecoratorList<emu-mods> [?Yield] opt</emu-mods></emu-nt><emu-t optional="">static</emu-t><emu-nt>PropertyName<emu-mods></emu-mods></emu-nt><emu-nt params="In, ?Yield" optional="">Initializer<emu-mods> [In, ?Yield] opt</emu-mods></emu-nt><emu-t>;</emu-t></emu-rhs>
|
||||
<emu-rhs><emu-t>;</emu-t></emu-rhs>
|
||||
</emu-production>
|
||||
<emu-production id="grammar-decoratorlist" name="DecoratorList" params="Yield">
|
||||
<emu-nt>DecoratorList<emu-mods> [Yield]</emu-mods><emu-mods></emu-mods></emu-nt><emu-geq>:</emu-geq><emu-rhs><emu-nt params="?Yield" optional="">DecoratorList<emu-mods> [?Yield] opt</emu-mods></emu-nt><emu-nt params="?Yield">Decorator<emu-mods> [?Yield]</emu-mods></emu-nt></emu-rhs>
|
||||
</emu-production>
|
||||
<emu-production id="grammar-decorator" name="Decorator" params="Yield">
|
||||
<emu-nt>Decorator<emu-mods> [Yield]</emu-mods><emu-mods></emu-mods></emu-nt><emu-geq>:</emu-geq><emu-rhs><emu-t>@</emu-t><emu-nt params="Decorator, ?Yield">LeftHandSideExpression<emu-mods> [Decorator, ?Yield]</emu-mods></emu-nt></emu-rhs>
|
||||
</emu-production>
|
||||
</emu-annex>
|
||||
|
||||
<emu-annex id="scripts-and-modules">
|
||||
<h1><span class="secnum">A.3</span>Scripts and Modules</h1>
|
||||
<emu-production id="grammar-exportdeclaration" name="ExportDeclaration">
|
||||
<emu-nt>ExportDeclaration<emu-mods></emu-mods><emu-mods></emu-mods></emu-nt><emu-geq>:</emu-geq><emu-rhs><emu-t>export</emu-t><emu-t>*</emu-t><emu-nt>FromClause<emu-mods></emu-mods></emu-nt><emu-t>;</emu-t></emu-rhs>
|
||||
<emu-rhs><emu-t>export</emu-t><emu-nt>ExportClause<emu-mods></emu-mods></emu-nt><emu-nt>FromClause<emu-mods></emu-mods></emu-nt><emu-t>;</emu-t></emu-rhs>
|
||||
<emu-rhs><emu-t>export</emu-t><emu-nt>ExportClause<emu-mods></emu-mods></emu-nt><emu-t>;</emu-t></emu-rhs>
|
||||
<emu-rhs><emu-t>export</emu-t><emu-nt>VariableStatement<emu-mods></emu-mods></emu-nt></emu-rhs>
|
||||
<emu-rhs><emu-t>export</emu-t><emu-gann>[lookahead ≠ <emu-t>@</emu-t>]</emu-gann><emu-nt>Declaration<emu-mods></emu-mods></emu-nt></emu-rhs>
|
||||
<emu-rhs><emu-t>export</emu-t><emu-t>default</emu-t><emu-nt params="Default">HoistableDeclaration<emu-mods> [Default]</emu-mods></emu-nt></emu-rhs>
|
||||
<emu-rhs><emu-t>export</emu-t><emu-t>default</emu-t><emu-gann>[lookahead ≠ <emu-t>@</emu-t>]</emu-gann><emu-nt params="Default">ClassDeclaration<emu-mods> [Default]</emu-mods></emu-nt></emu-rhs>
|
||||
<emu-rhs><emu-t>export</emu-t><emu-t>default</emu-t><emu-gann>[lookahead ∉ { <emu-t>function</emu-t>, <emu-t>class</emu-t>, <emu-t>@</emu-t> }]</emu-gann><emu-nt>AssignmentExpression<emu-mods></emu-mods></emu-nt></emu-rhs>
|
||||
<emu-rhs><emu-nt>DecoratorList<emu-mods></emu-mods></emu-nt><emu-t>export</emu-t><emu-gann>[lookahead ≠ <emu-t>@</emu-t>]</emu-gann><emu-nt>ClassDeclaration<emu-mods></emu-mods></emu-nt></emu-rhs>
|
||||
<emu-rhs><emu-nt>DecoratorList<emu-mods></emu-mods></emu-nt><emu-t>export</emu-t><emu-t>default</emu-t><emu-gann>[lookahead ≠ <emu-t>@</emu-t>]</emu-gann><emu-nt params="Default">ClassDeclaration<emu-mods> [Default]</emu-mods></emu-nt></emu-rhs>
|
||||
</emu-production>
|
||||
</emu-annex>
|
||||
</emu-annex>
|
||||
<emu-annex id="typescript">
|
||||
<h1><span class="secnum">B</span>TypeScript</h1>
|
||||
<emu-annex id="typescript-definitions">
|
||||
<h1><span class="secnum">B.1</span>TypeScript Definitions</h1>
|
||||
<pre><code class="typescript hljs"><span class="hljs-interface"><span class="hljs-keyword">interface</span> TypedPropertyDescriptor<T> </span>{
|
||||
enumerable?: <span class="hljs-built_in">boolean</span>;
|
||||
configurable?: <span class="hljs-built_in">boolean</span>;
|
||||
writable?: <span class="hljs-built_in">boolean</span>;
|
||||
value?: T;
|
||||
<span class="hljs-keyword">get</span>?: () => T;
|
||||
<span class="hljs-keyword">set</span>?: (value: T) => <span class="hljs-built_in">void</span>;
|
||||
}
|
||||
|
||||
type ClassDecorator = <span class="xml"><span class="hljs-tag"><<span class="hljs-title">TFunction</span> <span class="hljs-attribute">extends</span> <span class="hljs-attribute">Function</span>></span>(target: TFunction): TFunction | void;
|
||||
type MethodDecorator = <span class="hljs-tag"><<span class="hljs-title">T</span>></span>(target: Object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<span class="hljs-tag"><<span class="hljs-title">T</span>></span>): TypedPropertyDescriptor<span class="hljs-tag"><<span class="hljs-title">T</span>></span> | void;
|
||||
type PropertyDecorator = (target: Object, propertyKey: string | symbol): void;
|
||||
type ParameterDecorator = (target: Object, propertyKey: string | symbol, parameterIndex: number): void;
|
||||
</span></code></pre>
|
||||
</emu-annex>
|
||||
</emu-annex></body>
|
441
node_modules/reflect-metadata/spec/typescript.html
generated
vendored
Normal file
441
node_modules/reflect-metadata/spec/typescript.html
generated
vendored
Normal file
@ -0,0 +1,441 @@
|
||||
<meta charset="utf8">
|
||||
<title>Decorators</title>
|
||||
<link rel="stylesheet" href="./css/elements.css">
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.4/styles/github.min.css">
|
||||
<emu-biblio href="./biblio.json"></emu-biblio>
|
||||
|
||||
<h1>Decorators Proposal - TypeScript</h1>
|
||||
<emu-intro id="introduction">
|
||||
<h1>Introduction</h1>
|
||||
<p>Proposal to add Decorators to TypeScript.</p>
|
||||
<p>For the ECMAScript specific proposal, see <a href="index.html">http://rbuckton.github.io/reflectdecorators/index.html</a></p>
|
||||
</emu-intro>
|
||||
|
||||
<emu-clause id="proposal-terms">
|
||||
<h1>Terms</h1>
|
||||
<emu-clause id="proposal-terms-decorator">
|
||||
<h1>Decorator</h1>
|
||||
<emu-note>This section is non-normative.</emu-note>
|
||||
<p>A <em>decorator</em> is an expression that is evaluated after a class has been defined, that can be used to annotate or modify the class in some fashion. This expression must evaluate to a <code>function</code>, which is executed by the runtime to apply the decoration.</p>
|
||||
<pre><code class="typescript">@decoratorExpression
|
||||
class C {
|
||||
}
|
||||
</code></pre>
|
||||
</emu-clause>
|
||||
<emu-clause id="proposal-terms-classdecoratorfunction">
|
||||
<h1>Class Decorator Function</h1>
|
||||
<emu-note>This section is non-normative.</emu-note>
|
||||
<p>A <em>class decorator function</em> is a function that accepts a constructor function as its argument, and returns either <code>undefined</code>, the provided constructor function, or a new constructor function. Returning <code>undefined</code> is equivalent to returning the provided constructor function.</p>
|
||||
<pre><code class="typescript">// A class decorator function
|
||||
function dec(target) {
|
||||
// modify, annotate, or replace target...
|
||||
}
|
||||
</code></pre>
|
||||
</emu-clause>
|
||||
<emu-clause id="proposal-terms-propertydecoratorfunction">
|
||||
<h1>Property/Method Decorator Function</h1>
|
||||
<emu-note>This section is non-normative.</emu-note>
|
||||
<p>A <em>property decorator function</em> is a function that accepts three arguments: The object that owns the property, the key for the property (a <code>string</code> or a <code>symbol</code>), and optionally the property descriptor of the property. The function must return either <code>undefined</code>, the provided property descriptor, or a new property descriptor. Returning <code>undefined</code> is equivalent to returning the provided property descriptor.</p>
|
||||
<pre><code class="typescript">// A property (or method/accessor) decorator function
|
||||
function dec(target, key, descriptor) {
|
||||
// annotate the target and key; or modify or replace the descriptor...
|
||||
}
|
||||
</code></pre>
|
||||
</emu-clause>
|
||||
<emu-clause id="proposal-terms-parameterdecoratorfunction">
|
||||
<h1>Parameter Decorator Function</h1>
|
||||
<emu-note>This section is non-normative.</emu-note>
|
||||
<p>A <em>parameter decorator function</em> is a function that accepts three arguments: The function that contains the decorated parameter, the property key of the member (or <code>undefined</code> for a parameter of the constructor), and the ordinal index of the parameter. The return value of this decorator is ignored.</p>
|
||||
<pre><code class="typescript">
|
||||
// A parameter decorator
|
||||
function dec(target, paramIndex) {
|
||||
// annotate the target and index
|
||||
}
|
||||
</code></pre>
|
||||
</emu-clause>
|
||||
<emu-clause id="proposal-terms-decoratorfactory">
|
||||
<h1>Decorator Factory</h1>
|
||||
<emu-note>This section is non-normative.</emu-note>
|
||||
<p>A <em>decorator factory</em> is a function that can accept any number of arguments, and must return one of the above types of decorator function.</p>
|
||||
<pre><code class="typescript">// a class decorator factory function
|
||||
function dec(x, y) {
|
||||
// the class decorator function
|
||||
return function (target) {
|
||||
// modify, annotate, or replace target...
|
||||
}
|
||||
}
|
||||
</code></pre>
|
||||
</emu-clause>
|
||||
</emu-clause>
|
||||
<emu-clause id="proposal-decoratortargets">
|
||||
<h1>Decorator Targets</h1>
|
||||
<emu-note>This section is non-normative.</emu-note>
|
||||
<p>A <em>decorator</em> <strong>can</strong> be legally applied to any of the following:</p>
|
||||
<ul>
|
||||
<li>A class declaration</li>
|
||||
<li>A class property initializer (static or prototype)</li>
|
||||
<li>A class method declaration (static or prototype)</li>
|
||||
<li>A class get or set accessor declaration (static or prototype)</li>
|
||||
<li>A parameter of a class constructor</li>
|
||||
<li>A parameter of a class method (static or prototype)</li>
|
||||
<li>A parameter of a class get or set accessor (static or prototype)</li>
|
||||
</ul>
|
||||
<p>Please note that a <em>decorator</em> currently <strong>cannot</strong> be legally applied to any of the following:</p>
|
||||
<ul>
|
||||
<li>A class constructor - This is to reduce ambiguity between where you can apply a decorator (on the class or on its constructor) and which of the above decorator function forms is called.</li>
|
||||
<li>A function declaration - Decorators on a function declaration would introduce a TDZ (Temporal Dead Zone), which would make the function unreachable until its declaration is executed. This could cause confusion as an undecorated function declaration is hoisted and can be used in a statement preceeding the declaration.</li>
|
||||
<li>A function expression - This is to reduce confusion and maintain parity with disallowing decorators on a function declaration.</li>
|
||||
<li>An arrow function - This is to reduce confusion and maintain parity with disallowing decorators on a function expression.</li>
|
||||
</ul>
|
||||
<p>This list may change in the future.</p>
|
||||
</emu-clause>
|
||||
<emu-clause id="proposal-decoratoreval">
|
||||
<h1>Decorator Evaluation and Application Order</h1>
|
||||
<emu-note>This section is non-normative.</emu-note>
|
||||
<p>Decorators are <em>evaluated</em> in the order they appear preceeding their target declaration, to preserve side-effects due to evaluation order. Decorators are <em>applied</em> to their target declaration in reverse order, starting with the decorator closest to the declaration. This behavior is specified to preserve the expected behavior of decorators without a declarative syntax.</p>
|
||||
<pre><code class="typescript">@F
|
||||
@G
|
||||
class C {
|
||||
}
|
||||
</code></pre>
|
||||
<p>For example, the above listing could be approximately written without decorators in the following fashion:</p>
|
||||
<pre><code class="typescript">C = F(G(C))</code></pre>
|
||||
<p>In the above example, the expression <code>F</code> is evaluated first, followed by the expression <code>G</code>. <code>G</code> is then called with the constructor function as its argument, followed by calling <code>F</code> with the result. The actual process of applying decorators is more complex than the above example however, though you may still imperatively apply decorators with a reflection API.</p>
|
||||
<p>If a class declaration has decorators on both the class and any of its members or parameters, the decorators are applied using the following pseudocode:</p>
|
||||
<pre>
|
||||
for each member M of class C
|
||||
if M is an accessor then
|
||||
let accessor = first accessor (get or set, in declaration order) of M
|
||||
let memberDecorators = decorators of accessor
|
||||
for each parameter of accessor
|
||||
let paramDecorators = decorators of parameter
|
||||
let paramIndex = ordinal index of parameter
|
||||
Reflect.decorate(paramDecorators, accessor, paramIndex)
|
||||
next parameter
|
||||
|
||||
let accessor = second accessor (get or set, in declaration order) of M
|
||||
if accessor then
|
||||
let memberDecorators = memberDecorators + decorators of accessor
|
||||
for each parameter of accessor
|
||||
let paramDecorators = decorators of parameter
|
||||
let paramIndex = ordinal index of parameter
|
||||
Reflect.decorate(paramDecorators, accessor, paramIndex)
|
||||
next parameter
|
||||
end if
|
||||
else if M is a method
|
||||
let memberDecorators = decorators of M
|
||||
for each parameter of M
|
||||
let paramDecorators = decorators of parameter
|
||||
let paramIndex = ordinal index of parameter
|
||||
Reflect.decorate(paramDecorators, M, paramIndex)
|
||||
next parameter
|
||||
else
|
||||
let memberDecorators = decorators of M
|
||||
end if
|
||||
|
||||
let name = name of M
|
||||
let target = C.prototype if M is on the prototype; otherwise, C if M is static
|
||||
Reflect.decorate(memberDecorators, C, name)
|
||||
next member
|
||||
|
||||
for each parameter of C
|
||||
let paramDecorators = decorators of parameter
|
||||
let paramIndex = ordinal index of parameter
|
||||
Reflect.decorate(paramDecorators, C, paramIndex)
|
||||
next parameter
|
||||
|
||||
let classDecorators = decorators of C
|
||||
let C = Reflect.decorate(classDecorators, C)
|
||||
</pre>
|
||||
</emu-clause>
|
||||
|
||||
<emu-clause id="reflect">
|
||||
<h1>Reflect API</h1>
|
||||
<emu-note>This section is non-normative.</emu-note>
|
||||
<p>In addition to a declarative approach to defining decorators, it is necessary to also include an imperative API capable of applying decorators, as well as defining, reflecting over, and removing decorator metadata from an object, property, or parameter.</p>
|
||||
<p>A shim for this API can be found here: <a href="https://github.com/rbuckton/ReflectDecorators">https://github.com/rbuckton/ReflectDecorators</a></p>
|
||||
<pre><code class="typescript">Reflect.decorate(decorators, target, propertyKey?, descriptor?)</code></pre>
|
||||
</emu-clause>
|
||||
|
||||
<emu-clause id="transpile">
|
||||
<h1>Transformation</h1>
|
||||
<p>The following are examples of how decorators can be desugared to ES6 (through a transpiler such as TypeScript). These examples levarage an imperative reflection API.</p>
|
||||
<emu-clause id="transpile-class">
|
||||
<h1>Class Declaration</h1>
|
||||
<h2>Syntax</h2>
|
||||
<pre><code class="typescript">@F("color")
|
||||
@G
|
||||
class C {
|
||||
}
|
||||
</code></pre>
|
||||
<h2>ES6 Transformation</h2>
|
||||
<pre><code class="javascript">let C = class {
|
||||
}
|
||||
Object.defineProperty(C, "name", { value: "C", configurable: true });
|
||||
C = __decorate([F("color"), G], C);
|
||||
</code></pre>
|
||||
</emu-clause>
|
||||
|
||||
<emu-clause id="transpile-exportclass">
|
||||
<h1>Class Declaration (Exported)</h1>
|
||||
<h2>Syntax</h2>
|
||||
<pre><code class="typescript">@F("color")
|
||||
@G
|
||||
export class C {
|
||||
}
|
||||
</code></pre>
|
||||
<h2>ES6 Transformation</h2>
|
||||
<pre><code class="javascript">export let C = class {
|
||||
}
|
||||
Object.defineProperty(C, "name", { value: "C", configurable: true });
|
||||
C = __decorate([F("color"), G], C);
|
||||
</code></pre>
|
||||
</emu-clause>
|
||||
|
||||
<emu-clause id="transpile-exportdefaultclass">
|
||||
<h1>Class Declaration (Default, Exported)</h1>
|
||||
<h2>Syntax</h2>
|
||||
<pre><code class="typescript">@F("color")
|
||||
@G
|
||||
export default class C {
|
||||
}
|
||||
</code></pre>
|
||||
<h2>ES6 Transformation</h2>
|
||||
<pre><code class="javascript">let C = class {
|
||||
}
|
||||
Object.defineProperty(C, "name", { value: "C", configurable: true });
|
||||
C = __decorate([F("color"), G], C);
|
||||
export default C;
|
||||
</code></pre>
|
||||
</emu-clause>
|
||||
|
||||
<emu-clause id="transpile-classmethod">
|
||||
<h1>Class Method Declaration</h1>
|
||||
<h2>Syntax</h2>
|
||||
<pre><code class="typescript">class C {
|
||||
@F("color")
|
||||
@G
|
||||
method() { }
|
||||
}
|
||||
</code></pre>
|
||||
<h2>ES6 Transformation</h2>
|
||||
<pre><code class="javascript">class C {
|
||||
method() { }
|
||||
}
|
||||
Object.defineProperty(C.prototype, "method",
|
||||
__decorate([F("color"), G], C.prototype, "method", Object.getOwnPropertyDescriptor(C.prototype, "method")));
|
||||
</code></pre>
|
||||
</emu-clause>
|
||||
|
||||
<emu-clause id="transpile-classaccessor">
|
||||
<h1>Class Accessor Declaration</h1>
|
||||
<h2>Syntax</h2>
|
||||
<pre><code class="typescript">class C {
|
||||
@F("color")
|
||||
@G
|
||||
get accessor() { }
|
||||
set accessor(value) { }
|
||||
}
|
||||
</code></pre>
|
||||
<h2>ES6 Transformation</h2>
|
||||
<pre><code class="javascript">class C {
|
||||
get accessor() { }
|
||||
set accessor(value) { }
|
||||
}
|
||||
Object.defineProperty(C.prototype, "accessor",
|
||||
__decorate([F("color"), G], C.prototype, "accessor", Object.getOwnPropertyDescriptor(C.prototype, "accessor")));
|
||||
</code></pre>
|
||||
</emu-clause>
|
||||
|
||||
<emu-clause id="transpile-classproperty">
|
||||
<h1>Class Property Declaration</h1>
|
||||
<h2>Syntax</h2>
|
||||
<pre><code class="typescript">class C {
|
||||
@F("color")
|
||||
@G
|
||||
property = 1;
|
||||
}
|
||||
</code></pre>
|
||||
<h2>ES6 Transformation</h2>
|
||||
<pre><code class="javascript">class C {
|
||||
constructor() {
|
||||
this.property = 1;
|
||||
}
|
||||
}
|
||||
__decorate([F("color"), G], C.prototype, "property");
|
||||
</code></pre>
|
||||
</emu-clause>
|
||||
|
||||
<emu-clause id="transpile-classconstructorparameter">
|
||||
<h1>Class Constructor Parameter Declaration</h1>
|
||||
<h2>Syntax</h2>
|
||||
<pre><code class="typescript">class C {
|
||||
constructor(@F("color") @G p) { }
|
||||
}
|
||||
</code></pre>
|
||||
<h2>ES6 Transformation</h2>
|
||||
<pre><code class="javascript">class C {
|
||||
constructor(p) { }
|
||||
}
|
||||
__decorate([F("color"), G], C, void 0, 0);
|
||||
</code></pre>
|
||||
</emu-clause>
|
||||
|
||||
<emu-clause id="transpile-classmethodparameter">
|
||||
<h1>Class Method Parameter Declaration</h1>
|
||||
<h2>Syntax</h2>
|
||||
<pre><code class="typescript">class C {
|
||||
method(@F("color") @G p) { }
|
||||
}
|
||||
</code></pre>
|
||||
<h2>ES6 Transformation</h2>
|
||||
<pre><code class="javascript">class C {
|
||||
method(p) { }
|
||||
}
|
||||
__decorate([F("color"), G], C.prototype, "method", 0);
|
||||
</code></pre>
|
||||
</emu-clause>
|
||||
|
||||
<emu-clause id="transpile-classaccessorparameter">
|
||||
<h1>Class Set Accessor Parameter Declaration</h1>
|
||||
<h2>Syntax</h2>
|
||||
<pre><code class="typescript">class C {
|
||||
set accessor(@F("color") @G p) { }
|
||||
}
|
||||
</code></pre>
|
||||
<h2>ES6 Transformation</h2>
|
||||
<pre><code class="javascript">class C {
|
||||
set accessor(p) { }
|
||||
}
|
||||
__decorate([F("color"), G], C.prototype, "accessor", 0);
|
||||
</code></pre>
|
||||
</emu-clause>
|
||||
|
||||
</emu-clause>
|
||||
|
||||
<emu-annex id="grammar">
|
||||
<h1>Grammar</h1>
|
||||
<emu-annex id="grammar-expressions">
|
||||
<h1>Expressions</h1>
|
||||
<emu-production id="grammar-memberexpression" name="MemberExpression" params="Yield, Decorator">
|
||||
<emu-rhs><emu-nt params="?Yield">PrimaryExpression</emu-nt></emu-rhs>
|
||||
<emu-rhs constraints="~Decorator"><emu-nt params="?Yield, ?Decorator">MemberExpression</emu-nt><emu-t>[</emu-t><emu-nt params="In, ?Yield">Expression</emu-nt><emu-t>]</emu-t></emu-rhs>
|
||||
<emu-rhs><emu-nt params="?Yield, ?Decorator">MemberExpression</emu-nt><emu-t>.</emu-t><emu-nt>IdentifierName</emu-nt></emu-rhs>
|
||||
<emu-rhs><emu-nt params="?Yield, ?Decorator">MemberExpression</emu-nt><emu-nt params="?Yield">TemplateLiteral</emu-nt></emu-rhs>
|
||||
<emu-rhs><emu-nt params="?Yield, ?Decorator">SuperProperty</emu-nt></emu-rhs>
|
||||
<emu-rhs><emu-nt>MetaProperty</emu-nt></emu-rhs>
|
||||
<emu-rhs><emu-t>new</emu-t><emu-nt params="?Yield, ?Decorator">MemberExpression</emu-nt><emu-nt params="?Yield">Arguments</emu-nt></emu-rhs>
|
||||
</emu-production>
|
||||
<emu-production id="grammar-superproperty" name="SuperProperty" params="Yield, Decorator">
|
||||
<emu-rhs constraints="~Decorator"><emu-t>super</emu-t><emu-t>[</emu-t><emu-nt params="In, ?Yield">Expression</emu-nt><emu-t>]</emu-t></emu-rhs>
|
||||
</emu-production>
|
||||
<emu-production id="grammar-newexpression" name="NewExpression" params="Yield, Decorator">
|
||||
<emu-rhs><emu-nt params="?Yield, ?Decorator">MemberExpression</emu-nt></emu-rhs>
|
||||
<emu-rhs><emu-t>new</emu-t><emu-nt params="?Yield, ?Decorator">NewExpression</emu-nt></emu-rhs>
|
||||
</emu-production>
|
||||
<emu-production id="grammar-callexpression" name="CallExpression" params="Yield, Decorator">
|
||||
<emu-rhs><emu-nt params="?Yield, ?Decorator">MemberExpression</emu-nt> <emu-nt params="?Yield">Arguments</emu-nt></emu-rhs>
|
||||
<emu-rhs><emu-nt params="?Yield">SuperCall</emu-nt></emu-rhs>
|
||||
<emu-rhs><emu-nt params="?Yield, ?Decorator">CallExpression</emu-nt> <emu-nt params="?Yield">Arguments</emu-nt></emu-rhs>
|
||||
<emu-rhs constraints="~Decorator"><emu-nt params="?Yield">CallExpression</emu-nt> <emu-t>[</emu-t> <emu-nt params="In, ?Yield">Expression</emu-nt> <emu-t>]</emu-t></emu-rhs>
|
||||
<emu-rhs><emu-nt params="?Yield, ?Decorator">CallExpression</emu-nt> <emu-t>.</emu-t> <emu-nt>IdentifierName</emu-nt></emu-rhs>
|
||||
<emu-rhs><emu-nt params="?Yield, ?Decorator">CallExpression</emu-nt> <emu-nt params="?Yield">TemplateLiteral</emu-nt></emu-rhs>
|
||||
</emu-production>
|
||||
<emu-production id="grammar-lefthandsideexpression" name="LeftHandSideExpression" params="Yield, Decorator">
|
||||
<emu-rhs><emu-nt params="?Yield, ?Decorator">NewExpression</emu-nt></emu-rhs>
|
||||
<emu-rhs><emu-nt params="?Yield, ?Decorator">CallExpression</emu-nt></emu-rhs>
|
||||
</emu-production>
|
||||
</emu-annex>
|
||||
|
||||
<emu-annex id="functions-and-classes">
|
||||
<h1>Functions and Classes</h1>
|
||||
<emu-production id="grammar-strictformalparameters" name="StrictFormalParameters" params="Yield, GeneratorParameter, ClassParameter">
|
||||
<emu-rhs><emu-nt params="?Yield, ?GeneratorParameter, ?ClassParameter">FormalParameters</emu-nt></emu-rhs>
|
||||
</emu-production>
|
||||
<emu-production id="grammar-formalparameters" name="FormalParameters" params="Yield, GeneratorParameter, ClassParameter">
|
||||
<emu-rhs><emu-prose>[empty]</emu-prose></emu-rhs>
|
||||
<emu-rhs><emu-nt params="?Yield, ?GeneratorParameter, ?ClassParameter">FormalParameterList</emu-nt></emu-rhs>
|
||||
</emu-production>
|
||||
<emu-production id="grammar-formalparameterlist" name="FormalParameterList" params="Yield, GeneratorParameter, ClassParameter">
|
||||
<emu-rhs><emu-nt params="?Yield, ?ClassParameter">FunctionRestParameter</emu-nt></emu-rhs>
|
||||
<emu-rhs><emu-nt params="?Yield, ?GeneratorParameter, ?ClassParameter">FormalsList</emu-nt></emu-rhs>
|
||||
<emu-rhs><emu-nt params="?Yield, ?GeneratorParameter, ?ClassParameter">FormalsList</emu-nt><emu-t>,</emu-t><emu-nt params="?Yield, ?ClassParameter">FunctionRestParameter</emu-nt></emu-rhs>
|
||||
</emu-production>
|
||||
<emu-production id="grammar-formalslist" name="FormalsList" params="Yield, GeneratorParameter, ClassParameter">
|
||||
<emu-rhs><emu-nt params="?Yield, ?GeneratorParameter, ?ClassParameter">FormalParameter</emu-nt></emu-rhs>
|
||||
<emu-rhs><emu-nt params="?Yield, ?GeneratorParameter, ?ClassParameter">FormalsList</emu-nt><emu-t>,</emu-t><emu-nt params="?Yield, ?GeneratorParameter, ?ClassParameter">FormalParameter</emu-nt></emu-rhs>
|
||||
</emu-production>
|
||||
<emu-production id="grammar-functionrestparameter" name="FunctionRestParameter" params="Yield, ClassParameter">
|
||||
<emu-rhs><emu-nt params="?Yield">BindingRestElement</emu-nt></emu-rhs>
|
||||
<emu-rhs constraints="+ClassParameter"><emu-nt>DecoratorList</emu-nt><emu-nt params="?Yield">BindingRestElement</emu-nt></emu-rhs>
|
||||
</emu-production>
|
||||
<emu-production id="grammar-formalparameter" name="FormalParameter" params="Yield, GeneratorParameter, ClassParameter">
|
||||
<emu-rhs><emu-nt params="?Yield, ?GeneratorParameter">BindingElement</emu-nt></emu-rhs>
|
||||
<emu-rhs constraints="+ClassParameter"><emu-nt>DecoratorList</emu-nt><emu-nt params="?Yield, ?GeneratorParameter">BindingElement</emu-nt></emu-rhs>
|
||||
</emu-production>
|
||||
<emu-production id="grammar-methoddefinition" name="MethodDefinition" params="Yield, ClassParameter">
|
||||
<emu-rhs><emu-nt params="?Yield">PropertyName</emu-nt> <emu-t>(</emu-t> <emu-nt params="?ClassParameter">StrictFormalParameters</emu-nt> <emu-t>)</emu-t> <emu-t>{</emu-t> <emu-nt>FunctionBody</emu-nt> <emu-t>}</emu-t></emu-rhs>
|
||||
<emu-rhs><emu-nt params="?Yield, ?ClassParameter">GeneratorMethod</emu-nt></emu-rhs>
|
||||
<emu-rhs><emu-t>get</emu-t><emu-nt params="?Yield">PropertyName</emu-nt> <emu-t>(</emu-t> <emu-t>)</emu-t> <emu-t>{</emu-t> <emu-nt>FunctionBody</emu-nt> <emu-t>}</emu-t></emu-rhs>
|
||||
<emu-rhs><emu-t>set</emu-t><emu-nt params="?Yield">PropertyName</emu-nt> <emu-t>(</emu-t> <emu-nt params="?ClassParameter">PropertySetParameterList</emu-nt> <emu-t>)</emu-t> <emu-t>{</emu-t> <emu-nt>FunctionBody</emu-nt> <emu-t>}</emu-t></emu-rhs>
|
||||
</emu-production>
|
||||
<emu-production id="grammar-generatormethod" name="GeneratorMethod" params="Yield, ClassParameter">
|
||||
<emu-rhs><emu-t>*</emu-t><emu-nt params="?Yield">PropertyName</emu-nt> <emu-t>(</emu-t> <emu-nt params="Yield, GeneratorParameter, ?ClassParameter">StrictFormalParameters</emu-nt> <emu-t>)</emu-t> <emu-t>{</emu-t> <emu-nt>GeneratorBody</emu-nt> <emu-t>}</emu-t></emu-rhs>
|
||||
</emu-production>
|
||||
<emu-production id="grammar-classdeclaration" name="ClassDeclaration" params="Yield, Default">
|
||||
<emu-rhs><emu-nt params="?Yield" optional>DecoratorList</emu-nt> <emu-t>class</emu-t> <emu-nt params="?Yield">BindingIdentifier</emu-nt> <emu-nt params="?Yield">ClassTail</emu-nt></emu-rhs>
|
||||
<emu-rhs constraints="+Default"><emu-nt params="?Yield" optional>DecoratorList</emu-nt> <emu-t>class</emu-t> <emu-nt params="?Yield">ClassTail</emu-nt></emu-rhs>
|
||||
</emu-production>
|
||||
<emu-production id="grammar-classexpression" name="ClassExpression" params="Yield, GeneratorParameter">
|
||||
<emu-rhs><emu-nt params="?Yield" optional>DecoratorList</emu-nt> <emu-t>class</emu-t> <emu-nt params="?Yield" optional>BindingIdentifier</emu-nt> <emu-nt params="?Yield, ?GeneratorParameter">ClassTail</emu-nt></emu-rhs>
|
||||
</emu-production>
|
||||
<emu-production id="grammar-classelement" name="ClassElement" params="Yield">
|
||||
<emu-rhs><emu-nt params="?Yield" optional>DecoratorList</emu-nt> <emu-nt params="ClassParameter, ?Yield">MethodDefinition</emu-nt></emu-rhs>
|
||||
<emu-rhs><emu-nt params="?Yield" optional>DecoratorList</emu-nt> <emu-t>static</emu-t> <emu-nt params="ClassParameter, ?Yield">MethodDefinition</emu-nt></emu-rhs>
|
||||
<emu-rhs><emu-nt params="?Yield" optional>DecoratorList</emu-nt> <emu-t optional>static</emu-t> <emu-nt>PropertyName</emu-nt> <emu-nt params="In, ?Yield" optional>Initializer</emu-nt> <emu-t>;</emu-t></emu-rhs>
|
||||
<emu-rhs><emu-t>;</emu-t></emu-rhs>
|
||||
</emu-production>
|
||||
<emu-production id="grammar-decoratorlist" name="DecoratorList" params="Yield">
|
||||
<emu-rhs><emu-nt params="?Yield" optional>DecoratorList</emu-nt> <emu-nt params="?Yield">Decorator</emu-nt></emu-rhs>
|
||||
</emu-production>
|
||||
<emu-production id="grammar-decorator" name="Decorator" params="Yield">
|
||||
<emu-rhs><emu-t>@</emu-t> <emu-nt params="Decorator, ?Yield">LeftHandSideExpression</emu-nt></emu-rhs>
|
||||
</emu-production>
|
||||
</emu-annex>
|
||||
|
||||
<emu-annex id="scripts-and-modules">
|
||||
<h1>Scripts and Modules</h1>
|
||||
<emu-production id="grammar-exportdeclaration" name="ExportDeclaration">
|
||||
<emu-rhs><emu-t>export</emu-t> <emu-t>*</emu-t> <emu-nt>FromClause</emu-nt> <emu-t>;</emu-t></emu-rhs>
|
||||
<emu-rhs><emu-t>export</emu-t> <emu-nt>ExportClause</emu-nt> <emu-nt>FromClause</emu-nt> <emu-t>;</emu-t></emu-rhs>
|
||||
<emu-rhs><emu-t>export</emu-t> <emu-nt>ExportClause</emu-nt> <emu-t>;</emu-t></emu-rhs>
|
||||
<emu-rhs><emu-t>export</emu-t> <emu-nt>VariableStatement</emu-nt></emu-rhs>
|
||||
<emu-rhs><emu-t>export</emu-t> <emu-gann>lookahead ≠ <emu-t>@</emu-t></emu-gann> <emu-nt>Declaration</emu-nt></emu-rhs>
|
||||
<emu-rhs><emu-t>export</emu-t> <emu-t>default</emu-t> <emu-nt params="Default">HoistableDeclaration</emu-nt></emu-rhs>
|
||||
<emu-rhs><emu-t>export</emu-t> <emu-t>default</emu-t> <emu-gann>lookahead ≠ <emu-t>@</emu-t></emu-gann> <emu-nt params="Default">ClassDeclaration</emu-nt></emu-rhs>
|
||||
<emu-rhs><emu-t>export</emu-t> <emu-t>default</emu-t> <emu-gann>lookahead ∉ { <emu-t>function</emu-t>, <emu-t>class</emu-t>, <emu-t>@</emu-t> }</emu-gann> <emu-nt>AssignmentExpression</emu-nt></emu-rhs>
|
||||
<emu-rhs><emu-nt>DecoratorList</emu-nt> <emu-t>export</emu-t> <emu-gann>lookahead ≠ <emu-t>@</emu-t></emu-gann> <emu-nt>ClassDeclaration</emu-nt></emu-rhs>
|
||||
<emu-rhs><emu-nt>DecoratorList</emu-nt> <emu-t>export</emu-t> <emu-t>default</emu-t> <emu-gann>lookahead ≠ <emu-t>@</emu-t></emu-gann> <emu-nt params="Default">ClassDeclaration</emu-nt></emu-rhs>
|
||||
</emu-production>
|
||||
</emu-annex>
|
||||
</emu-annex>
|
||||
<emu-annex id="typescript">
|
||||
<h1>TypeScript</h1>
|
||||
<emu-annex id="typescript-definitions">
|
||||
<h1>TypeScript Definitions</h1>
|
||||
<pre><code class="typescript">interface TypedPropertyDescriptor<T> {
|
||||
enumerable?: boolean;
|
||||
configurable?: boolean;
|
||||
writable?: boolean;
|
||||
value?: T;
|
||||
get?: () => T;
|
||||
set?: (value: T) => void;
|
||||
}
|
||||
|
||||
type ClassDecorator = <TFunction extends Function>(target: TFunction): TFunction | void;
|
||||
type MethodDecorator = <T>(target: Object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T> | void;
|
||||
type PropertyDecorator = (target: Object, propertyKey: string | symbol): void;
|
||||
type ParameterDecorator = (target: Object, propertyKey: string | symbol, parameterIndex: number): void;
|
||||
</code></pre>
|
||||
</emu-annex>
|
||||
</emu-annex>
|
Reference in New Issue
Block a user