1/*
2 * Copyright (c) 2022-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
16import './short_test.ts'; // import from path
17
18import { test } from './short_test.ts';
19
20function withStmt() {
21  const radius = 12;
22  with (Math) {
23    const area = PI * radius * radius;
24  }
25}
26
27namespace X {
28  export class C {}
29  export interface I {
30    f: number;
31  }
32  export const n = 15;
33  export enum E {}
34  export function foo(a: number): number {
35    return a * a;
36  }
37  export type N = number;
38
39  export namespace XX {
40    export class D {}
41  }
42
43  console.log('Namespace X is initialized');
44  {
45    console.log('Block statement');
46    const blockVar = 10;
47  }
48}
49const xc = new X.C();
50class IImpl implements X.I {
51  f = 10;
52}
53const xn: X.N = X.foo(100);
54const d: X.XX.D = new X.XX.D();
55
56namespace Y.Z {
57  export function bar(): void {
58    const x = 200;
59  }
60}
61Y.Z.bar();
62
63// Namespace used as an object or type.
64const x = X;
65console.log(x.n);
66
67const xxx = X.XX;
68const dd = new xxx.D();
69
70function xfoo(x: typeof X): void {
71  x.foo(25);
72}
73xfoo(X);
74
75function yzbar(yz: typeof Y.Z): void {
76  yz.bar();
77}
78yzbar(Y.Z);
79
80import { default as def } from 'module'; // default import
81
82interface I {
83  f: number;
84}
85export default I; // default interface export
86export default function (n: number) {
87  n++;
88} // default function export
89export default class MyClass {} // default class export
90
91// type-only import
92import type { APIResponseType } from './api';
93import type * as P from 'foo';
94import { type T1, type T2 as T3 } from 'foobar';
95
96// type-only export
97export type { TypeA as TypeB };
98export { type TypeFoo as TypeBar };
99
100// Re-exporting
101export * from 'module1'; // Ok
102export * as Utilities from 'module2'; // Ok
103export { SomeFunction, SomeType as OtherType } from 'module3'; // Ok
104
105class Point {}
106export = Point;
107
108import Validator = require('module');
109import Button = Components.Button;
110
111let m = require('moduleM');
112const k = require('moduleK');
113
114export { Point };
115export { Point as P };
116export default Point;
117
118export { someFunction1 } from 'module3'
119export { default as someFunction2 } from 'module3'
120