1/* 2* Copyright (c) Microsoft Corporation. All rights reserved. 3* Copyright (c) 2023 Huawei Device Co., Ltd. 4* Licensed under the Apache License, Version 2.0 (the "License"); 5* you may not use this file except in compliance with the License. 6* You may obtain a copy of the License at 7* 8* http://www.apache.org/licenses/LICENSE-2.0 9* 10* Unless required by applicable law or agreed to in writing, software 11* distributed under the License is distributed on an "AS IS" BASIS, 12* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13* See the License for the specific language governing permissions and 14* limitations under the License. 15* 16* This file has been modified by Huawei to verify type inference by adding verification statements. 17*/ 18 19// === tests/cases/compiler/commentsCommentParsing.ts === 20declare function AssertType(value:any, type:string):void; 21/// This is simple /// comments 22function simple() { 23} 24 25simple(); 26AssertType(simple(), "void"); 27AssertType(simple, "() => void"); 28 29/// multiLine /// Comments 30/// This is example of multiline /// comments 31/// Another multiLine 32function multiLine() { 33} 34multiLine(); 35AssertType(multiLine(), "void"); 36AssertType(multiLine, "() => void"); 37 38/** this is eg of single line jsdoc style comment */ 39function jsDocSingleLine() { 40} 41jsDocSingleLine(); 42AssertType(jsDocSingleLine(), "void"); 43AssertType(jsDocSingleLine, "() => void"); 44 45 46/** this is multiple line jsdoc stule comment 47*New line1 48*New Line2*/ 49function jsDocMultiLine() { 50} 51jsDocMultiLine(); 52AssertType(jsDocMultiLine(), "void"); 53AssertType(jsDocMultiLine, "() => void"); 54 55/** this is multiple line jsdoc stule comment 56*New line1 57*New Line2*/ 58/** Shoul mege this line as well 59* and this too*/ /** Another this one too*/ 60function jsDocMultiLineMerge() { 61} 62jsDocMultiLineMerge(); 63AssertType(jsDocMultiLineMerge(), "void"); 64AssertType(jsDocMultiLineMerge, "() => void"); 65 66 67/// Triple slash comment 68/** jsdoc comment */ 69function jsDocMixedComments1() { 70} 71jsDocMixedComments1(); 72AssertType(jsDocMixedComments1(), "void"); 73AssertType(jsDocMixedComments1, "() => void"); 74 75/// Triple slash comment 76/** jsdoc comment */ /*** another jsDocComment*/ 77function jsDocMixedComments2() { 78} 79jsDocMixedComments2(); 80AssertType(jsDocMixedComments2(), "void"); 81AssertType(jsDocMixedComments2, "() => void"); 82 83/** jsdoc comment */ /*** another jsDocComment*/ 84/// Triple slash comment 85function jsDocMixedComments3() { 86} 87jsDocMixedComments3(); 88AssertType(jsDocMixedComments3(), "void"); 89AssertType(jsDocMixedComments3, "() => void"); 90 91/** jsdoc comment */ /*** another jsDocComment*/ 92/// Triple slash comment 93/// Triple slash comment 2 94function jsDocMixedComments4() { 95} 96jsDocMixedComments4(); 97AssertType(jsDocMixedComments4(), "void"); 98AssertType(jsDocMixedComments4, "() => void"); 99 100/// Triple slash comment 1 101/** jsdoc comment */ /*** another jsDocComment*/ 102/// Triple slash comment 103/// Triple slash comment 2 104function jsDocMixedComments5() { 105} 106jsDocMixedComments5(); 107AssertType(jsDocMixedComments5(), "void"); 108AssertType(jsDocMixedComments5, "() => void"); 109 110/*** another jsDocComment*/ 111/// Triple slash comment 1 112/// Triple slash comment 113/// Triple slash comment 2 114/** jsdoc comment */ 115function jsDocMixedComments6() { 116} 117jsDocMixedComments6(); 118AssertType(jsDocMixedComments6(), "void"); 119AssertType(jsDocMixedComments6, "() => void"); 120 121// This shoulnot be help comment 122function noHelpComment1() { 123} 124noHelpComment1(); 125AssertType(noHelpComment1(), "void"); 126AssertType(noHelpComment1, "() => void"); 127 128/* This shoulnot be help comment */ 129function noHelpComment2() { 130} 131noHelpComment2(); 132AssertType(noHelpComment2(), "void"); 133AssertType(noHelpComment2, "() => void"); 134 135function noHelpComment3() { 136} 137noHelpComment3(); 138AssertType(noHelpComment3(), "void"); 139AssertType(noHelpComment3, "() => void"); 140 141/** Adds two integers and 142returns the result 143 * @param {number} a first number 144 * @param b second number 145 */ 146function sum(a: number, b: number) { 147AssertType(a + b, "number"); 148AssertType(a, "number"); 149AssertType(b, "number"); 150 return a + b; 151} 152sum(10, 20); 153AssertType(sum(10, 20), "number"); 154AssertType(sum, "(number, number) => number"); 155AssertType(10, "int"); 156AssertType(20, "int"); 157 158/** This is multiplication function*/ 159/** @param */ 160/** @param a first number*/ 161/** @param b */ 162/** @param c { 163 @param d @anotherTag*/ 164/** @param e LastParam @anotherTag*/ 165function multiply(a: number, b: number, c?: number, d?, e?) { 166} 167/** fn f1 with number 168* @param { string} b about b 169*/ 170function f1(a: number); 171function f1(b: string); 172/**@param opt optional parameter*/ 173function f1(aOrb, opt?) { 174AssertType(aOrb, "any"); 175 return aOrb; 176} 177/** This is subtract function 178@param { a 179*@param { number | } b this is about b 180@param { { () => string; } } c this is optional param c 181@param { { () => string; } d this is optional param d 182@param { { () => string; } } e this is optional param e 183@param { { { () => string; } } f this is optional param f 184*/ 185function subtract(a: number, b: number, c?: () => string, d?: () => string, e?: () => string, f?: () => string) { 186} 187/** this is square function 188@paramTag { number } a this is input number of paramTag 189@param { number } a this is input number 190@ 191returnType { number } it is return type 192*/ 193function square(a: number) { 194AssertType(a * a, "number"); 195AssertType(a, "number"); 196AssertType(a, "number"); 197 return a * a; 198} 199/** this is divide function 200@param { number} a this is a 201@paramTag { number } g this is optional param g 202@param { number} b this is b 203*/ 204function divide(a: number, b: number) { 205} 206/** this is jsdoc style function with param tag as well as inline parameter help 207*@param a it is first parameter 208*@param c it is third parameter 209*/ 210function jsDocParamTest(/** this is inline comment for a */a: number, /** this is inline comment for b*/ b: number, c: number, d: number) { 211AssertType(a + b + c + d, "number"); 212AssertType(a + b + c, "number"); 213AssertType(a + b, "number"); 214AssertType(a, "number"); 215AssertType(b, "number"); 216AssertType(c, "number"); 217AssertType(d, "number"); 218 return a + b + c + d; 219} 220 221/**/ 222class NoQuickInfoClass { 223} 224 225