javascript @param 和@return 注释中的感叹号表示什么?
what does an exclamation mark indicate in javascript @param and @return comments?
我正在尝试关注 this guideline:
/** A class that does something. */
class SomeClass extends SomeBaseClass {
/**
* Operates on an instance of MyClass and returns something.
* @param {!MyClass} obj An object that for some reason needs detailed
* explanation that spans multiple lines.
* @param {!OtherClass} obviousOtherClass
* @return {boolean} Whether something occurred.
*/
someMethod(obj, obviousOtherClass) { ... }
/** @override */
overriddenMethod(param) { ... }
}
/**
* Demonstrates how top-level functions follow the same rules. This one
* makes an array.
* @param {TYPE} arg
* @return {!Array<TYPE>}
* @template TYPE
*/
function makeArray(arg) { ... }
我想知道感叹号在 @param {!MyClass}
或 @return {!Array<TYPE>}
中的含义以及何时使用它。
根据 Use JSDoc: @type 上的 table,在 "Non-nullable type" 的行中,前面的感叹号表示 "non-null" .
我正在尝试关注 this guideline:
/** A class that does something. */
class SomeClass extends SomeBaseClass {
/**
* Operates on an instance of MyClass and returns something.
* @param {!MyClass} obj An object that for some reason needs detailed
* explanation that spans multiple lines.
* @param {!OtherClass} obviousOtherClass
* @return {boolean} Whether something occurred.
*/
someMethod(obj, obviousOtherClass) { ... }
/** @override */
overriddenMethod(param) { ... }
}
/**
* Demonstrates how top-level functions follow the same rules. This one
* makes an array.
* @param {TYPE} arg
* @return {!Array<TYPE>}
* @template TYPE
*/
function makeArray(arg) { ... }
我想知道感叹号在 @param {!MyClass}
或 @return {!Array<TYPE>}
中的含义以及何时使用它。
根据 Use JSDoc: @type 上的 table,在 "Non-nullable type" 的行中,前面的感叹号表示 "non-null" .