1// @noEmit: true 2// @allowJs: true 3// @checkJs: true 4 5// @Filename: mod1.js 6 7/** 8 * @typedef {function(string): boolean} 9 * Type1 10 */ 11 12/** 13 * Tries to use a type whose name is on a different 14 * line than the typedef tag. 15 * @param {Type1} func The function to call. 16 * @param {string} arg The argument to call it with. 17 * @returns {boolean} The return. 18 */ 19function callIt(func, arg) { 20 return func(arg); 21} 22 23// @Filename: mod2.js 24 25/** 26 * @typedef {{ 27 * num: number, 28 * str: string, 29 * boo: boolean 30 * }} Type2 31 */ 32 33/** 34 * Makes use of a type with a multiline type expression. 35 * @param {Type2} obj The object. 36 * @returns {string|number} The return. 37 */ 38function check(obj) { 39 return obj.boo ? obj.num : obj.str; 40} 41 42// @Filename: mod3.js 43 44/** 45 * A function whose signature is very long. 46 * 47 * @typedef {function(boolean, string, number): 48 * (string|number)} StringOrNumber1 49 */ 50 51/** 52 * Makes use of a function type with a long signature. 53 * @param {StringOrNumber1} func The function. 54 * @param {boolean} bool The condition. 55 * @param {string} str The string. 56 * @param {number} num The number. 57 * @returns {string|number} The return. 58 */ 59function use1(func, bool, str, num) { 60 return func(bool, str, num) 61} 62 63// @Filename: mod4.js 64 65/** 66 * A function whose signature is very long. 67 * 68 * @typedef {function(boolean, string, 69 * number): 70 * (string|number)} StringOrNumber2 71 */ 72 73/** 74 * Makes use of a function type with a long signature. 75 * @param {StringOrNumber2} func The function. 76 * @param {boolean} bool The condition. 77 * @param {string} str The string. 78 * @param {number} num The number. 79 * @returns {string|number} The return. 80 */ 81function use2(func, bool, str, num) { 82 return func(bool, str, num) 83} 84 85// @Filename: mod5.js 86 87/** 88 * @typedef {{ 89 * num: 90 * number, 91 * str: 92 * string, 93 * boo: 94 * boolean 95 * }} Type5 96 */ 97 98/** 99 * Makes use of a type with a multiline type expression. 100 * @param {Type5} obj The object. 101 * @returns {string|number} The return. 102 */ 103function check5(obj) { 104 return obj.boo ? obj.num : obj.str; 105} 106 107// @Filename: mod6.js 108 109/** 110 * @typedef {{ 111 * foo: 112 * *, 113 * bar: 114 * * 115 * }} Type6 116 */ 117 118/** 119 * Makes use of a type with a multiline type expression. 120 * @param {Type6} obj The object. 121 * @returns {*} The return. 122 */ 123function check6(obj) { 124 return obj.foo; 125} 126 127 128// @Filename: mod7.js 129 130/** 131 Multiline type expressions in comments without leading * are not supported. 132 @typedef {{ 133 foo: 134 *, 135 bar: 136 * 137 }} Type7 138 */ 139