Skip to content

Commit 17e437b

Browse files
author
Kanchalai Tanglertsampan
committed
Add compiler baseline-tests for using --lib node
1 parent b01b5af commit 17e437b

7 files changed

Lines changed: 198 additions & 0 deletions
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
//// [modularizeLibrary_UsingES5LibAndNodeLib.ts]
2+
3+
import fs = require("fs");
4+
import Console = require("console");
5+
6+
var myLog = new Console.Console(fs.createWriteStream(".\Output"));
7+
myLog.log("Logging to myLog");
8+
myLog.trace("show me the trace");
9+
10+
console.log("No Error using node console");
11+
console.log(`Current Directory ${process.cwd()}`);
12+
console.error("Report error");
13+
14+
15+
//// [modularizeLibrary_UsingES5LibAndNodeLib.js]
16+
"use strict";
17+
var fs = require("fs");
18+
var Console = require("console");
19+
var myLog = new Console.Console(fs.createWriteStream(".\Output"));
20+
myLog.log("Logging to myLog");
21+
myLog.trace("show me the trace");
22+
console.log("No Error using node console");
23+
console.log("Current Directory " + process.cwd());
24+
console.error("Report error");
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
=== tests/cases/compiler/modularizeLibrary_UsingES5LibAndNodeLib.ts ===
2+
3+
import fs = require("fs");
4+
>fs : Symbol(fs, Decl(modularizeLibrary_UsingES5LibAndNodeLib.ts, 0, 0))
5+
6+
import Console = require("console");
7+
>Console : Symbol(Console, Decl(modularizeLibrary_UsingES5LibAndNodeLib.ts, 1, 26))
8+
9+
var myLog = new Console.Console(fs.createWriteStream(".\Output"));
10+
>myLog : Symbol(myLog, Decl(modularizeLibrary_UsingES5LibAndNodeLib.ts, 4, 3))
11+
>Console.Console : Symbol(Console.Console, Decl(lib.node.d.ts, --, --))
12+
>Console : Symbol(Console, Decl(modularizeLibrary_UsingES5LibAndNodeLib.ts, 1, 26))
13+
>Console : Symbol(Console.Console, Decl(lib.node.d.ts, --, --))
14+
>fs.createWriteStream : Symbol(fs.createWriteStream, Decl(lib.node.d.ts, --, --))
15+
>fs : Symbol(fs, Decl(modularizeLibrary_UsingES5LibAndNodeLib.ts, 0, 0))
16+
>createWriteStream : Symbol(fs.createWriteStream, Decl(lib.node.d.ts, --, --))
17+
18+
myLog.log("Logging to myLog");
19+
>myLog.log : Symbol(NodeJS.Console.log, Decl(lib.node.d.ts, --, --))
20+
>myLog : Symbol(myLog, Decl(modularizeLibrary_UsingES5LibAndNodeLib.ts, 4, 3))
21+
>log : Symbol(NodeJS.Console.log, Decl(lib.node.d.ts, --, --))
22+
23+
myLog.trace("show me the trace");
24+
>myLog.trace : Symbol(NodeJS.Console.trace, Decl(lib.node.d.ts, --, --))
25+
>myLog : Symbol(myLog, Decl(modularizeLibrary_UsingES5LibAndNodeLib.ts, 4, 3))
26+
>trace : Symbol(NodeJS.Console.trace, Decl(lib.node.d.ts, --, --))
27+
28+
console.log("No Error using node console");
29+
>console.log : Symbol(Console.log, Decl(lib.node.d.ts, --, --))
30+
>console : Symbol(Console, Decl(lib.node.d.ts, --, --))
31+
>log : Symbol(Console.log, Decl(lib.node.d.ts, --, --))
32+
33+
console.log(`Current Directory ${process.cwd()}`);
34+
>console.log : Symbol(Console.log, Decl(lib.node.d.ts, --, --))
35+
>console : Symbol(Console, Decl(lib.node.d.ts, --, --))
36+
>log : Symbol(Console.log, Decl(lib.node.d.ts, --, --))
37+
>process.cwd : Symbol(NodeJS.Process.cwd, Decl(lib.node.d.ts, --, --))
38+
>process : Symbol(process, Decl(lib.node.d.ts, --, --))
39+
>cwd : Symbol(NodeJS.Process.cwd, Decl(lib.node.d.ts, --, --))
40+
41+
console.error("Report error");
42+
>console.error : Symbol(Console.error, Decl(lib.node.d.ts, --, --))
43+
>console : Symbol(Console, Decl(lib.node.d.ts, --, --))
44+
>error : Symbol(Console.error, Decl(lib.node.d.ts, --, --))
45+
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
=== tests/cases/compiler/modularizeLibrary_UsingES5LibAndNodeLib.ts ===
2+
3+
import fs = require("fs");
4+
>fs : typeof fs
5+
6+
import Console = require("console");
7+
>Console : typeof Console
8+
9+
var myLog = new Console.Console(fs.createWriteStream(".\Output"));
10+
>myLog : NodeJS.Console
11+
>new Console.Console(fs.createWriteStream(".\Output")) : NodeJS.Console
12+
>Console.Console : new (stdout: NodeJS.WritableStream, stderr?: NodeJS.WritableStream) => NodeJS.Console
13+
>Console : typeof Console
14+
>Console : new (stdout: NodeJS.WritableStream, stderr?: NodeJS.WritableStream) => NodeJS.Console
15+
>fs.createWriteStream(".\Output") : fs.WriteStream
16+
>fs.createWriteStream : (path: string, options?: { flags?: string; encoding?: string; fd?: number; mode?: number; }) => fs.WriteStream
17+
>fs : typeof fs
18+
>createWriteStream : (path: string, options?: { flags?: string; encoding?: string; fd?: number; mode?: number; }) => fs.WriteStream
19+
>".\Output" : string
20+
21+
myLog.log("Logging to myLog");
22+
>myLog.log("Logging to myLog") : void
23+
>myLog.log : (data?: any, ...optionalParams: any[]) => void
24+
>myLog : NodeJS.Console
25+
>log : (data?: any, ...optionalParams: any[]) => void
26+
>"Logging to myLog" : string
27+
28+
myLog.trace("show me the trace");
29+
>myLog.trace("show me the trace") : void
30+
>myLog.trace : (message: any, ...optionalParams: any[]) => void
31+
>myLog : NodeJS.Console
32+
>trace : (message: any, ...optionalParams: any[]) => void
33+
>"show me the trace" : string
34+
35+
console.log("No Error using node console");
36+
>console.log("No Error using node console") : void
37+
>console.log : (data?: any, ...optionalParams: any[]) => void
38+
>console : typeof Console
39+
>log : (data?: any, ...optionalParams: any[]) => void
40+
>"No Error using node console" : string
41+
42+
console.log(`Current Directory ${process.cwd()}`);
43+
>console.log(`Current Directory ${process.cwd()}`) : void
44+
>console.log : (data?: any, ...optionalParams: any[]) => void
45+
>console : typeof Console
46+
>log : (data?: any, ...optionalParams: any[]) => void
47+
>`Current Directory ${process.cwd()}` : string
48+
>process.cwd() : string
49+
>process.cwd : () => string
50+
>process : NodeJS.Process
51+
>cwd : () => string
52+
53+
console.error("Report error");
54+
>console.error("Report error") : void
55+
>console.error : (data?: any, ...optionalParams: any[]) => void
56+
>console : typeof Console
57+
>error : (data?: any, ...optionalParams: any[]) => void
58+
>"Report error" : string
59+
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
lib.dom.d.ts(12899,13): error TS2300: Duplicate identifier 'console'.
2+
lib.node.d.ts(157,19): error TS2300: Duplicate identifier 'console'.
3+
tests/cases/compiler/modularizeLibrary_UsingES5LibNodeLibAndDomLib.ts(5,25): error TS2339: Property 'Console' does not exist on type 'Console'.
4+
5+
6+
==== tests/cases/compiler/modularizeLibrary_UsingES5LibNodeLibAndDomLib.ts (1 errors) ====
7+
8+
import fs = require("fs");
9+
import Console = require("console");
10+
11+
var myLog = new Console.Console(fs.createWriteStream(".\Output"));
12+
~~~~~~~
13+
!!! error TS2339: Property 'Console' does not exist on type 'Console'.
14+
myLog.log("Logging to myLog");
15+
myLog.trace("show me the trace");
16+
17+
console.log("No Error using node console");
18+
console.log(`Current Directory ${process.cwd()}`);
19+
console.error("Report error");
20+
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
//// [modularizeLibrary_UsingES5LibNodeLibAndDomLib.ts]
2+
3+
import fs = require("fs");
4+
import Console = require("console");
5+
6+
var myLog = new Console.Console(fs.createWriteStream(".\Output"));
7+
myLog.log("Logging to myLog");
8+
myLog.trace("show me the trace");
9+
10+
console.log("No Error using node console");
11+
console.log(`Current Directory ${process.cwd()}`);
12+
console.error("Report error");
13+
14+
15+
//// [modularizeLibrary_UsingES5LibNodeLibAndDomLib.js]
16+
"use strict";
17+
var fs = require("fs");
18+
var Console = require("console");
19+
var myLog = new Console.Console(fs.createWriteStream(".\Output"));
20+
myLog.log("Logging to myLog");
21+
myLog.trace("show me the trace");
22+
console.log("No Error using node console");
23+
console.log("Current Directory " + process.cwd());
24+
console.error("Report error");
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// @lib: es5,node
2+
// @target: es5
3+
4+
import fs = require("fs");
5+
import Console = require("console");
6+
7+
var myLog = new Console.Console(fs.createWriteStream(".\Output"));
8+
myLog.log("Logging to myLog");
9+
myLog.trace("show me the trace");
10+
11+
console.log("No Error using node console");
12+
console.log(`Current Directory ${process.cwd()}`);
13+
console.error("Report error");
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// @lib: es5,node,dom
2+
// @target: es5
3+
4+
import fs = require("fs");
5+
import Console = require("console");
6+
7+
var myLog = new Console.Console(fs.createWriteStream(".\Output"));
8+
myLog.log("Logging to myLog");
9+
myLog.trace("show me the trace");
10+
11+
console.log("No Error using node console");
12+
console.log(`Current Directory ${process.cwd()}`);
13+
console.error("Report error");

0 commit comments

Comments
 (0)