• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2025 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
16import { Foo, foo, CreatePerson, a , b, MyNamespace } from "./no_js_instanceof_file.js"
17
18class Foo1 {}
19
20let foo1 = new Foo1()
21
22if(foo1 instanceof Foo1) {
23
24}
25
26if(foo instanceof Foo) {
27
28}
29
30if(foo1 instanceof Foo) {
31
32}
33
34if(foo instanceof Foo1) {
35
36}
37
38let person: CreatePerson = CreatePerson('xc', 18)
39
40if(person instanceof CreatePerson) {
41
42}
43
44function test1(): void {
45    if(person instanceof CreatePerson) {
46
47    }
48}
49
50const test2 = (): void => {
51    if(person instanceof CreatePerson) {
52
53    }
54}
55
56class Test3 {
57    init(): void {
58        if(person instanceof CreatePerson) {
59
60        }
61    }
62}
63
64if(a instanceof Array) {
65
66}
67
68if(b() instanceof Array) {
69
70}
71
72const myDog: MyNamespace.Dog = new MyNamespace.Dog('Buddy');
73
74if (myDog instanceof MyNamespace.Dog) {
75  console.log("This is a Dog!");
76}