1/* 2 * Copyright (c) 2023-2024 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16let a = +5 // 5 as number 17let b = +"5" // 5 as number 18let c = -5 // -5 as number 19let d = -"5" // -5 as number 20let e = ~5 // -6 as number 21let f = ~"5" // -6 as number 22let g = +"string" // NaN as number 23 24function returnTen(): string { 25 return "-10" 26} 27 28function returnString(): string { 29 return "string" 30} 31 32let x = +returnTen() // -10 as number 33let y = +returnString() // NaN 34 35let t1: BigInt = BigInt(1) 36 37let t2 = -t1; 38let t3 = -9007199254740991n; 39 40let t4 = -(new Number(1)) 41let t5 = -(BigInt(1)) 42