Skip to content

Commit 5505441

Browse files
zhengzongyihegemonic
authored andcommitted
add example of optional property (#176)
Fixes: #172
1 parent 7491db0 commit 5505441

File tree

2 files changed

+25
-4
lines changed

2 files changed

+25
-4
lines changed

content/en/tags-property.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,17 @@ var config = {
5050
};
5151
```
5252
{% endexample %}
53+
54+
The following example shows how to indicate that a property is optional.
55+
56+
{% example "A type definition with required and optional property" %}
57+
58+
```
59+
/**
60+
* User type definition
61+
* @typedef {Object} User
62+
* @property {string} email
63+
* @property {string} [nickName]
64+
*/
65+
```
66+
{% endexample %}

tags-property.html

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,16 @@ <h2 id="examples">Examples</h2>
6969
}
7070
}
7171
};
72-
</code></pre>
73-
</figure>
72+
</code></pre></figure>
73+
<p>The following example shows how to indicate that a property is optional.</p>
74+
<figure>
75+
<figcaption>A type definition with required and optional property</figcaption><pre class="prettyprint"><code>/**
76+
* User type definition
77+
* @typedef {Object} User
78+
* @property {string} email
79+
* @property {string} [nickName]
80+
*/
81+
</code></pre> </figure>
7482
<h2 id="related-links">Related Links</h2>
7583
<ul>
7684
<li>
@@ -83,8 +91,7 @@ <h2 id="related-links">Related Links</h2>
8391
</article>
8492
<footer>
8593
<a class="license-badge" href="http://creativecommons.org/licenses/by-sa/3.0/">
86-
<img alt="Creative Commons License" class="license-badge" src="images/cc-by-sa.svg" width="80" height="15" />
87-
</a>
94+
<img alt="Creative Commons License" class="license-badge" src="images/cc-by-sa.svg" width="80" height="15" /></a>
8895
<br> Copyright &#169; 2011-2017 the
8996
<a href="https://github.com/jsdoc3/jsdoc3.github.com/contributors">contributors</a> to the JSDoc 3 documentation project.
9097
<br> This website is <a href="https://github.com/jsdoc3/jsdoc3.github.com">open source</a> and is licensed under the <a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/">

0 commit comments

Comments
 (0)