• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2023 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/**---
16 description: >
17  That's exactly what TypeScript 3.7 introduces. At the "top level" of a type alias, TypeScript will defer resolving type arguments to permit these patterns.
18 module: ESNext
19 isCurrent: true
20---*/
21
22
23import { Assert } from '../../../suite/assert.js'
24
25type JSONType =
26    | string
27    | number
28    | boolean
29    | null
30    | JsonObjectX
31    | JsonArray;
32
33interface JsonObjectX {
34    [property: string]: JSONType;
35}
36
37interface JsonArray extends Array<JSONType> { }
38const myJson: JSONType = ["a", 2, true, null, {
39    "Damage": 1024,
40    "DamageType": "XO",
41}, []];
42
43Assert.equal(typeof myJson, "object");