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 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
|
//// [tests/cases/compiler/requireOfJsonFileTypes.ts] ////
//// [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];
//// [b.json]
{
"a": true,
"b": "hello",
"c": null,
"d": false
}
//// [c.json]
["a", null, "string"]
//// [d.json]
"dConfig"
//// [e.json]
-10
//// [f.json]
[-10, 30]
//// [g.json]
[true, false]
//// [out/b.json]
{
"a": true,
"b": "hello",
"c": null,
"d": false
}
//// [out/c.json]
["a", null, "string"]
//// [out/d.json]
"dConfig"
//// [out/e.json]
-10
//// [out/f.json]
[-10, 30]
//// [out/g.json]
[true, false]
//// [out/file1.js]
"use strict";
exports.__esModule = true;
var b = require("./b.json");
var c = require("./c.json");
var d = require("./d.json");
var e = require("./e.json");
var f = require("./f.json");
var g = require("./g.json");
var booleanLiteral, nullLiteral;
var stringLiteral;
var numberLiteral;
booleanLiteral = b.a;
stringLiteral = b.b;
nullLiteral = b.c;
booleanLiteral = b.d;
var stringOrNumberOrNull = c[0];
stringLiteral = d;
numberLiteral = e;
numberLiteral = f[0];
booleanLiteral = g[0];
|