1/* 2 * Copyright (c) 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 arrBuf = new ArrayBuffer(1); 17let arrBufView: ArrayBufferView = {buffer: arrBuf, byteLength: 1, byteOffset: 0}; 18let dataView = new DataView(arrBuf); 19arrBufView = dataView; 20 21let arrLike: ArrayLike<number> = []; 22let arrLikeBigInt: ArrayLike<bigint> = []; 23let float32Arr = new Float32Array(1); 24let float64Arr = new Float64Array(1); 25let int8Arr = new Int8Array(1); 26let int16Arr = new Int16Array(1); 27let int32Arr = new Int32Array(1); 28let bigInt64Arr = new BigInt64Array(1); 29let uint8ClampedArr = new Uint8ClampedArray(1); 30let uint8Arr = new Uint8Array(1); 31let uint16Arr = new Uint16Array(1); 32let uint32Arr = new Uint32Array(1); 33let bigUint64Arr = new BigUint64Array(1); 34 35arrLike = float32Arr; 36arrLike = float64Arr; 37arrLike = int8Arr; 38arrLike = int16Arr; 39arrLike = int32Arr; 40arrLikeBigInt = bigInt64Arr; 41arrLike = uint8ClampedArr; 42arrLike = uint8Arr; 43arrLike = uint16Arr; 44arrLike = uint32Arr; 45arrLikeBigInt = bigUint64Arr; 46 47let concatArr: ConcatArray<number> = []; 48let readonlyArr: ReadonlyArray<number> = []; 49let arr = new Array<number>(); 50 51arrLike = concatArr; 52arrLike = readonlyArr; 53arrLike = arr; 54concatArr = readonlyArr; 55concatArr = arr; 56readonlyArr = arr; 57 58let readonlyMap: ReadonlyMap<string, string>; 59let map = new Map<string, string>(); 60let readonlySet: ReadonlySet<string>; 61let set = new Set<string>(); 62readonlyMap = map; 63readonlySet = set; 64 65class C1 { 66 a: number; 67} 68class C2<T> { 69 a: T; 70} 71let c1 = new C1(); 72let c2 = new C2<number>(); 73c1 = c2; // ERROR 74c2 = c1; // ERROR