Verify the output file paths for the json module emit

This commit is contained in:
Sheetal Nandi 2018-02-24 10:15:32 -08:00
parent 23a7e2f840
commit 4f1640d8e1
31 changed files with 189 additions and 29 deletions

View file

@ -15,12 +15,12 @@ if (x) {
"b": "hello"
}
//// [b.json]
//// [out/b.json]
{
"a": true,
"b": "hello"
}
//// [file1.js]
//// [out/file1.js]
"use strict";
exports.__esModule = true;
var b1 = require("./b.json");

View file

@ -21,7 +21,7 @@ if (x) {
"b": "hello"
}
//// [file1.js]
//// [out/file1.js]
"use strict";
exports.__esModule = true;
var b1 = require("b.json");

View file

@ -22,6 +22,6 @@ import e = require("e"); // Should fail
"b": "hello"
}
//// [file1.js]
//// [out/file1.js]
"use strict";
exports.__esModule = true;

View file

@ -13,10 +13,10 @@ let fnumber: number = f;
//// [f.ts]
export = 10;
//// [f.js]
//// [out/node_modules/f.js]
"use strict";
module.exports = 10;
//// [file1.js]
//// [out/projects/file1.js]
"use strict";
exports.__esModule = true;
var f = require("f"); // should work to f.ts

View file

@ -45,24 +45,24 @@ booleanLiteral = g[0];
//// [g.json]
[true, false]
//// [b.json]
//// [out/b.json]
{
"a": true,
"b": "hello",
"c": null,
"d": false
}
//// [c.json]
//// [out/c.json]
["a", null, "string"]
//// [d.json]
//// [out/d.json]
"dConfig"
//// [e.json]
//// [out/e.json]
-10
//// [f.json]
//// [out/f.json]
[-10, 30]
//// [g.json]
//// [out/g.json]
[true, false]
//// [file1.js]
//// [out/file1.js]
"use strict";
exports.__esModule = true;
var b = require("./b.json");

View file

@ -15,7 +15,7 @@ if (x) {
"b": "hello"
}
//// [file1.js]
//// [out/file1.js]
define(["require", "exports", "./b", "./b.json"], function (require, exports, b1, b2) {
"use strict";
exports.__esModule = true;

View file

@ -12,9 +12,9 @@ if (x) {
{
}
//// [b.json]
//// [out/b.json]
{}
//// [file1.js]
//// [out/file1.js]
"use strict";
exports.__esModule = true;
var b1 = require("./b.json");

View file

@ -13,9 +13,9 @@ if (x) {
{
}
//// [b.json]
//// [out/b.json]
{}
//// [file1.js]
//// [out/file1.js]
"use strict";
exports.__esModule = true;
var b1 = require("./b.json");

View file

@ -15,12 +15,12 @@ if (x) {
"b": "hello"
}
//// [b.json]
//// [out/b.json]
{
'a': true,
"b": "hello"
}
//// [file1.js]
//// [out/file1.js]
"use strict";
exports.__esModule = true;
var b1 = require("./b.json");

View file

@ -12,8 +12,8 @@ if (x) {
//// [b.json]
//// [b.json]
//// [file1.js]
//// [out/b.json]
//// [out/file1.js]
"use strict";
exports.__esModule = true;
var b1 = require("./b.json");

View file

@ -15,12 +15,12 @@ if (x) {
"b": "hello"
}
//// [b.json]
//// [out/b.json]
{
"a": true,
"b": "hello"
}
//// [file1.js]
//// [out/file1.js]
"use strict";
exports.__esModule = true;
var b1 = require("./b.json");

View file

@ -15,12 +15,12 @@ if (x) {
"b": "hello"
}
//// [b.json]
//// [out/b.json]
{
"a": true,
"b": "hello"
}
//// [file1.js]
//// [out/file1.js]
"use strict";
exports.__esModule = true;
var b1 = require("./b"); // This should not resolve

View file

@ -24,15 +24,15 @@ if (x2) {
//// [c.ts]
export = { a: true, b: "hello" };
//// [c.js]
//// [out/c.js]
"use strict";
module.exports = { a: true, b: "hello" };
//// [c.json]
//// [out/c.json]
{
"a": true,
"b": "hello"
}
//// [file1.js]
//// [out/file1.js]
"use strict";
exports.__esModule = true;
var c1 = require("./c"); // resolves to c.ts

View file

@ -0,0 +1,20 @@
error TS5055: Cannot write file 'tests/cases/compiler/b.json' because it would overwrite input file.
Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig.
!!! error TS5055: Cannot write file 'tests/cases/compiler/b.json' because it would overwrite input file.
!!! error TS5055: Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig.
==== tests/cases/compiler/file1.ts (0 errors) ====
import b1 = require('./b.json');
let x = b1.a;
import b2 = require('./b.json');
if (x) {
let b = b2.b;
x = (b1.b === b);
}
==== tests/cases/compiler/b.json (0 errors) ====
{
"a": true,
"b": "hello"
}

View file

@ -0,0 +1,27 @@
//// [tests/cases/compiler/requireOfJsonFileWithoutOutDir.ts] ////
//// [file1.ts]
import b1 = require('./b.json');
let x = b1.a;
import b2 = require('./b.json');
if (x) {
let b = b2.b;
x = (b1.b === b);
}
//// [b.json]
{
"a": true,
"b": "hello"
}
//// [tests/cases/compiler/file1.js]
"use strict";
exports.__esModule = true;
var b1 = require("./b.json");
var x = b1.a;
var b2 = require("./b.json");
if (x) {
var b = b2.b;
x = (b1.b === b);
}

View file

@ -0,0 +1,38 @@
=== tests/cases/compiler/file1.ts ===
import b1 = require('./b.json');
>b1 : Symbol(b1, Decl(file1.ts, 0, 0))
let x = b1.a;
>x : Symbol(x, Decl(file1.ts, 1, 3))
>b1.a : Symbol("a", Decl(b.json, 0, 1))
>b1 : Symbol(b1, Decl(file1.ts, 0, 0))
>a : Symbol("a", Decl(b.json, 0, 1))
import b2 = require('./b.json');
>b2 : Symbol(b2, Decl(file1.ts, 1, 13))
if (x) {
>x : Symbol(x, Decl(file1.ts, 1, 3))
let b = b2.b;
>b : Symbol(b, Decl(file1.ts, 4, 7))
>b2.b : Symbol("b", Decl(b.json, 1, 14))
>b2 : Symbol(b2, Decl(file1.ts, 1, 13))
>b : Symbol("b", Decl(b.json, 1, 14))
x = (b1.b === b);
>x : Symbol(x, Decl(file1.ts, 1, 3))
>b1.b : Symbol("b", Decl(b.json, 1, 14))
>b1 : Symbol(b1, Decl(file1.ts, 0, 0))
>b : Symbol("b", Decl(b.json, 1, 14))
>b : Symbol(b, Decl(file1.ts, 4, 7))
}
=== tests/cases/compiler/b.json ===
{
"a": true,
>"a" : Symbol("a", Decl(b.json, 0, 1))
"b": "hello"
>"b" : Symbol("b", Decl(b.json, 1, 14))
}

View file

@ -0,0 +1,45 @@
=== tests/cases/compiler/file1.ts ===
import b1 = require('./b.json');
>b1 : { "a": boolean; "b": string; }
let x = b1.a;
>x : boolean
>b1.a : boolean
>b1 : { "a": boolean; "b": string; }
>a : boolean
import b2 = require('./b.json');
>b2 : { "a": boolean; "b": string; }
if (x) {
>x : boolean
let b = b2.b;
>b : string
>b2.b : string
>b2 : { "a": boolean; "b": string; }
>b : string
x = (b1.b === b);
>x = (b1.b === b) : boolean
>x : boolean
>(b1.b === b) : boolean
>b1.b === b : boolean
>b1.b : string
>b1 : { "a": boolean; "b": string; }
>b : string
>b : string
}
=== tests/cases/compiler/b.json ===
{
>{ "a": true, "b": "hello"} : { "a": boolean; "b": string; }
"a": true,
>"a" : boolean
>true : true
"b": "hello"
>"b" : string
>"hello" : "hello"
}

View file

@ -1,6 +1,7 @@
// @module: commonjs
// @outdir: out/
// @allowJs: true
// @fullEmitPaths: true
// @Filename: file1.ts
import b1 = require('./b.json');

View file

@ -1,6 +1,7 @@
// @module: commonjs
// @outdir: out/
// @allowJs: true
// @fullEmitPaths: true
// @Filename: /src/projects/file1.ts
import b1 = require('b.json');

View file

@ -1,6 +1,7 @@
// @module: commonjs
// @outdir: out/
// @allowJs: true
// @fullEmitPaths: true
// @Filename: /src/projects/file1.ts
import d = require("d.json"); // Should fail

View file

@ -1,6 +1,7 @@
// @module: commonjs
// @outdir: out/
// @allowJs: true
// @fullEmitPaths: true
// @Filename: /src/projects/file1.ts
import f = require("f"); // should work to f.ts

View file

@ -2,6 +2,7 @@
// @outdir: out/
// @allowJs: true
// @strictNullChecks: true
// @fullEmitPaths: true
// @Filename: file1.ts
import b = require('./b.json');

View file

@ -1,6 +1,7 @@
// @module: amd
// @outdir: out/
// @allowJs: true
// @fullEmitPaths: true
// @Filename: file1.ts
import b1 = require('./b');

View file

@ -1,6 +1,7 @@
// @module: commonjs
// @outdir: out/
// @allowJs: true
// @fullEmitPaths: true
// @Filename: file1.ts
import b1 = require('./b.json');

View file

@ -1,6 +1,7 @@
// @module: commonjs
// @outdir: out/
// @allowJs: true
// @fullEmitPaths: true
// @Filename: file1.ts
import b1 = require('./b.json');

View file

@ -1,6 +1,7 @@
// @module: commonjs
// @outdir: out/
// @allowJs: true
// @fullEmitPaths: true
// @Filename: file1.ts
import b1 = require('./b.json');

View file

@ -1,6 +1,7 @@
// @module: commonjs
// @outdir: out/
// @allowJs: true
// @fullEmitPaths: true
// @Filename: file1.ts
import b1 = require('./b.json');

View file

@ -1,5 +1,6 @@
// @module: commonjs
// @outdir: out/
// @fullEmitPaths: true
// @Filename: file1.ts
import b1 = require('./b.json');

View file

@ -1,6 +1,7 @@
// @module: commonjs
// @outdir: out/
// @allowJs: true
// @fullEmitPaths: true
// @Filename: file1.ts
import b1 = require('./b'); // This should not resolve

View file

@ -1,6 +1,7 @@
// @module: commonjs
// @outdir: out/
// @allowJs: true
// @fullEmitPaths: true
// @Filename: file1.ts
import c1 = require('./c'); // resolves to c.ts

View file

@ -0,0 +1,17 @@
// @module: commonjs
// @fullEmitPaths: true
// @Filename: file1.ts
import b1 = require('./b.json');
let x = b1.a;
import b2 = require('./b.json');
if (x) {
let b = b2.b;
x = (b1.b === b);
}
// @Filename: b.json
{
"a": true,
"b": "hello"
}