Skip to content

Commit f3f5877

Browse files
committed
Add tests for noLib with <reference lib> and bundling.
1 parent cc7ddae commit f3f5877

File tree

4 files changed

+140
-0
lines changed

4 files changed

+140
-0
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
//// [tests/cases/conformance/declarationEmit/libReferenceNoLibBundle.ts] ////
2+
3+
//// [fakelib.ts]
4+
// Test that passing noLib disables <reference lib> resolution.
5+
6+
interface Object { }
7+
interface Array<T> { }
8+
interface String { }
9+
interface Boolean { }
10+
interface Number { }
11+
interface Function { }
12+
interface RegExp { }
13+
interface IArguments { }
14+
15+
16+
//// [file1.ts]
17+
/// <reference lib="dom" />
18+
export declare interface HTMLElement { field: string; }
19+
export const elem: HTMLElement = { field: 'a' };
20+
21+
22+
//// [bundle.js]
23+
// Test that passing noLib disables <reference lib> resolution.
24+
define("file1", ["require", "exports"], function (require, exports) {
25+
"use strict";
26+
Object.defineProperty(exports, "__esModule", { value: true });
27+
exports.elem = { field: 'a' };
28+
});
29+
30+
31+
//// [bundle.d.ts]
32+
interface Object {
33+
}
34+
interface Array<T> {
35+
}
36+
interface String {
37+
}
38+
interface Boolean {
39+
}
40+
interface Number {
41+
}
42+
interface Function {
43+
}
44+
interface RegExp {
45+
}
46+
interface IArguments {
47+
}
48+
declare module "file1" {
49+
export interface HTMLElement {
50+
field: string;
51+
}
52+
export const elem: HTMLElement;
53+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
=== tests/cases/conformance/declarationEmit/fakelib.ts ===
2+
// Test that passing noLib disables <reference lib> resolution.
3+
4+
interface Object { }
5+
>Object : Symbol(Object, Decl(fakelib.ts, 0, 0))
6+
7+
interface Array<T> { }
8+
>Array : Symbol(Array, Decl(fakelib.ts, 2, 20))
9+
>T : Symbol(T, Decl(fakelib.ts, 3, 16))
10+
11+
interface String { }
12+
>String : Symbol(String, Decl(fakelib.ts, 3, 22))
13+
14+
interface Boolean { }
15+
>Boolean : Symbol(Boolean, Decl(fakelib.ts, 4, 20))
16+
17+
interface Number { }
18+
>Number : Symbol(Number, Decl(fakelib.ts, 5, 21))
19+
20+
interface Function { }
21+
>Function : Symbol(Function, Decl(fakelib.ts, 6, 20))
22+
23+
interface RegExp { }
24+
>RegExp : Symbol(RegExp, Decl(fakelib.ts, 7, 22))
25+
26+
interface IArguments { }
27+
>IArguments : Symbol(IArguments, Decl(fakelib.ts, 8, 20))
28+
29+
30+
=== tests/cases/conformance/declarationEmit/file1.ts ===
31+
/// <reference lib="dom" />
32+
export declare interface HTMLElement { field: string; }
33+
>HTMLElement : Symbol(HTMLElement, Decl(file1.ts, 0, 0))
34+
>field : Symbol(HTMLElement.field, Decl(file1.ts, 1, 38))
35+
36+
export const elem: HTMLElement = { field: 'a' };
37+
>elem : Symbol(elem, Decl(file1.ts, 2, 12))
38+
>HTMLElement : Symbol(HTMLElement, Decl(file1.ts, 0, 0))
39+
>field : Symbol(field, Decl(file1.ts, 2, 34))
40+
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
=== tests/cases/conformance/declarationEmit/fakelib.ts ===
2+
// Test that passing noLib disables <reference lib> resolution.
3+
No type information for this code.
4+
No type information for this code.interface Object { }
5+
No type information for this code.interface Array<T> { }
6+
No type information for this code.interface String { }
7+
No type information for this code.interface Boolean { }
8+
No type information for this code.interface Number { }
9+
No type information for this code.interface Function { }
10+
No type information for this code.interface RegExp { }
11+
No type information for this code.interface IArguments { }
12+
No type information for this code.
13+
No type information for this code.
14+
No type information for this code.=== tests/cases/conformance/declarationEmit/file1.ts ===
15+
/// <reference lib="dom" />
16+
export declare interface HTMLElement { field: string; }
17+
>field : string
18+
19+
export const elem: HTMLElement = { field: 'a' };
20+
>elem : HTMLElement
21+
>{ field: 'a' } : { field: string; }
22+
>field : string
23+
>'a' : "a"
24+
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// @target: esnext
2+
// @module: amd
3+
// @noLib: true
4+
// @declaration: true
5+
// @outFile: bundle.js
6+
7+
// Test that passing noLib disables <reference lib> resolution.
8+
9+
// @filename: fakelib.ts
10+
interface Object { }
11+
interface Array<T> { }
12+
interface String { }
13+
interface Boolean { }
14+
interface Number { }
15+
interface Function { }
16+
interface RegExp { }
17+
interface IArguments { }
18+
19+
20+
// @filename: file1.ts
21+
/// <reference lib="dom" />
22+
export declare interface HTMLElement { field: string; }
23+
export const elem: HTMLElement = { field: 'a' };

0 commit comments

Comments
 (0)