Skip to content

Commit f07e3e8

Browse files
authored
Update JSDoc-support-in-JavaScript.md
Add documentation for @typedef tag, solves #117 .
1 parent bc01e11 commit f07e3e8

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

JSDoc-support-in-JavaScript.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
The below code outlines which constructs are currently supported or not supported
22
when using JsDoc annotations to provide type information in JavaScript files.
33

4-
Note any tags which are not explicitly listed below (such as `@typedef`, or `@constructor`)
4+
Note any tags which are not explicitly listed below (such as `@constructor`)
55
are not yet supported.
66

77
```javascript
88
// === Supported ===
99

1010
// You can use the "@type" tag and reference a type name (either primitive,
11-
// or defined in a TypeScript declaration)
11+
// defined in a TypeScript declaration, or in a JSDoc "@typedef" tag)
1212
/**
1313
* @type {string}
1414
*/
@@ -57,11 +57,19 @@ var var7;
5757
var var8;
5858

5959

60-
// An object specification may also be using within the braces
60+
// An object specification may also be used within the braces
6161
// For example, an object with properties 'a' (string) and 'b' (number)
6262
/** @type {{a: string, b: number}} */
6363
var var9;
6464

65+
// "@typedef" maybe used to define complex types
66+
/**
67+
* @typedef {Object} SpecialType - creates a new type named 'SpecialType'
68+
* @property {string} prop1 - a string property of SpecialType
69+
* @property {number} prop2 - a number property of SpecialType
70+
*/
71+
/** @type {SpecialType} */
72+
var specialTypeObject;
6573

6674
// Parameters may be declared in a variety of syntactic forms
6775

0 commit comments

Comments
 (0)