类型示例 变量示例 描述
number
    1
    1.0
    -5
    1e5
    Math.PI
                  
Number
new Number(true)
Number 对象
string
    'Hello'
    "World"
    String(42)
                  
String 值
String
    new String('Hello')
    new String(42)
                  
String 对象
boolean
    true
    false
    Boolean(0)
                  
Boolean 值
Boolean
new Boolean(true)
Boolean 对象
RegExp
    new RegExp('hello')
    /world/g
                  
Date
    new Date
    new Date()
                  
null
    null
                  
undefined
    undefined
                  
void
                    
    function f() {
      return;
    }
                    
                  
无返回值
Array
    ['foo', 0.3, null]
    []
                  
无类型数组
Array.<number>
    [11, 22, 33]
                  
数字数组
Array.<Array.<string>>
[['one', 'two', 'three'], ['foo', 'bar']]
字符串数组的数组
Object
{}
{foo: 'abc', bar: 123, baz: null}
Object.<string>
{'foo': 'bar'}
值为字符串的对象.
Object.<number, string>
var obj = {};
obj[1] = 'bar';
键为数字而值为字符串的对象.

注意在 JS 中, 键总是显式地转化为字符串类型, 因此 obj['1'] == obj[1]. 所以在 for...in 循环中键总是字符串类型. 但是, 当索引对象时, 编译器可以做到核验键的类型.
Function
function(x, y) {
  return x * y;
}
Function 对象
function(number, number): number
function(x, y) {
  return x * y;
}
                
function value
SomeClass
                    
/** @constructor */
function SomeClass() {}

new SomeClass();
                    
                  
SomeInterface
                    
/** @interface */
function SomeInterface() {}

SomeInterface.prototype.draw = function() {};
                    
                  
project.MyClass
                    
/** @constructor */
project.MyClass = function () {}

new project.MyClass()
                    
                  
project.MyEnum
                    
/** @enum {string} */
project.MyEnum = {
  /** The color blue. */
  BLUE: '#0000dd',
  /** The color red. */
  RED: '#dd0000'
};
                    
                  
Enumeration

对枚举类型的JSDoc 注释是可缺省的.
Element
document.createElement('div')
DOM 的元素.
Node
document.body.firstChild
DOM 的节点.
HTMLInputElement
htmlDocument.getElementsByTagName('input')[0]
标示 DOM 元素的类型.