File: requireOfJsonFileTypes.ts

package info (click to toggle)
node-typescript 3.3.3333-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 324,548 kB
  • sloc: makefile: 6; sh: 3
file content (51 lines) | stat: -rw-r--r-- 989 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// @module: commonjs
// @outdir: out/
// @allowJs: true
// @strictNullChecks: true
// @fullEmitPaths: true
// @resolveJsonModule: true

// @Filename: file1.ts
import b = require('./b.json');
import c = require('./c.json');
import d = require('./d.json');
import e = require('./e.json');
import f = require('./f.json');
import g = require('./g.json');

let booleanLiteral: boolean, nullLiteral: null;
let stringLiteral: string;
let numberLiteral: number;

booleanLiteral = b.a;
stringLiteral = b.b;
nullLiteral = b.c;
booleanLiteral = b.d;
const stringOrNumberOrNull: string | number | null = c[0];
stringLiteral = d;
numberLiteral = e;
numberLiteral = f[0];
booleanLiteral = g[0];

// @Filename: b.json
{
    "a": true,
    "b": "hello",
    "c": null,
    "d": false
}

// @Filename: c.json
["a", null, "string"]

// @Filename: d.json
"dConfig"

// @Filename: e.json
-10

// @Filename: f.json
[-10, 30]

// @Filename: g.json
[true, false]