Skip to content

Commit 45371af

Browse files
committed
Add tests from design meeting
1 parent 7f0b9ae commit 45371af

13 files changed

+553
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
fakeInfinity1.ts(17,1): error TS2322: Type 'number' is not assignable to type 'Infinity'.
2+
3+
4+
==== fakeInfinity1.ts (1 errors) ====
5+
// These are not actually the real infinity.
6+
export type PositiveInfinity = 1e999;
7+
export type NegativeInfinity = -1e999;
8+
9+
export type TypeOfInfinity = typeof Infinity;
10+
export type TypeOfNaN = typeof NaN;
11+
12+
type A = 1e999;
13+
type B = 1e9999;
14+
15+
declare let a: A;
16+
declare let b: B;
17+
18+
a = b;
19+
b = a;
20+
21+
a = Infinity;
22+
~
23+
!!! error TS2322: Type 'number' is not assignable to type 'Infinity'.
24+
a = 1e999;
25+
a = 1e9999;
26+
27+
export type Oops = 123456789123456789123456789123456789123456789123456789;
28+
export const oops = 123456789123456789123456789123456789123456789123456789;
29+
+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
//// [tests/cases/compiler/fakeInfinity1.ts] ////
2+
3+
//// [fakeInfinity1.ts]
4+
// These are not actually the real infinity.
5+
export type PositiveInfinity = 1e999;
6+
export type NegativeInfinity = -1e999;
7+
8+
export type TypeOfInfinity = typeof Infinity;
9+
export type TypeOfNaN = typeof NaN;
10+
11+
type A = 1e999;
12+
type B = 1e9999;
13+
14+
declare let a: A;
15+
declare let b: B;
16+
17+
a = b;
18+
b = a;
19+
20+
a = Infinity;
21+
a = 1e999;
22+
a = 1e9999;
23+
24+
export type Oops = 123456789123456789123456789123456789123456789123456789;
25+
export const oops = 123456789123456789123456789123456789123456789123456789;
26+
27+
28+
//// [fakeInfinity1.js]
29+
"use strict";
30+
Object.defineProperty(exports, "__esModule", { value: true });
31+
exports.oops = void 0;
32+
a = b;
33+
b = a;
34+
a = Infinity;
35+
a = 1e999;
36+
a = 1e9999;
37+
exports.oops = 123456789123456789123456789123456789123456789123456789;
38+
39+
40+
//// [fakeInfinity1.d.ts]
41+
export type PositiveInfinity = 1e999;
42+
export type NegativeInfinity = -1e999;
43+
export type TypeOfInfinity = typeof Infinity;
44+
export type TypeOfNaN = typeof NaN;
45+
export type Oops = 123456789123456789123456789123456789123456789123456789;
46+
export declare const oops = 1.2345678912345678e+53;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
//// [tests/cases/compiler/fakeInfinity1.ts] ////
2+
3+
=== fakeInfinity1.ts ===
4+
// These are not actually the real infinity.
5+
export type PositiveInfinity = 1e999;
6+
>PositiveInfinity : Symbol(PositiveInfinity, Decl(fakeInfinity1.ts, 0, 0))
7+
8+
export type NegativeInfinity = -1e999;
9+
>NegativeInfinity : Symbol(NegativeInfinity, Decl(fakeInfinity1.ts, 1, 37))
10+
11+
export type TypeOfInfinity = typeof Infinity;
12+
>TypeOfInfinity : Symbol(TypeOfInfinity, Decl(fakeInfinity1.ts, 2, 38))
13+
>Infinity : Symbol(Infinity, Decl(lib.es5.d.ts, --, --))
14+
15+
export type TypeOfNaN = typeof NaN;
16+
>TypeOfNaN : Symbol(TypeOfNaN, Decl(fakeInfinity1.ts, 4, 45))
17+
>NaN : Symbol(NaN, Decl(lib.es5.d.ts, --, --))
18+
19+
type A = 1e999;
20+
>A : Symbol(A, Decl(fakeInfinity1.ts, 5, 35))
21+
22+
type B = 1e9999;
23+
>B : Symbol(B, Decl(fakeInfinity1.ts, 7, 15))
24+
25+
declare let a: A;
26+
>a : Symbol(a, Decl(fakeInfinity1.ts, 10, 11))
27+
>A : Symbol(A, Decl(fakeInfinity1.ts, 5, 35))
28+
29+
declare let b: B;
30+
>b : Symbol(b, Decl(fakeInfinity1.ts, 11, 11))
31+
>B : Symbol(B, Decl(fakeInfinity1.ts, 7, 15))
32+
33+
a = b;
34+
>a : Symbol(a, Decl(fakeInfinity1.ts, 10, 11))
35+
>b : Symbol(b, Decl(fakeInfinity1.ts, 11, 11))
36+
37+
b = a;
38+
>b : Symbol(b, Decl(fakeInfinity1.ts, 11, 11))
39+
>a : Symbol(a, Decl(fakeInfinity1.ts, 10, 11))
40+
41+
a = Infinity;
42+
>a : Symbol(a, Decl(fakeInfinity1.ts, 10, 11))
43+
>Infinity : Symbol(Infinity, Decl(lib.es5.d.ts, --, --))
44+
45+
a = 1e999;
46+
>a : Symbol(a, Decl(fakeInfinity1.ts, 10, 11))
47+
48+
a = 1e9999;
49+
>a : Symbol(a, Decl(fakeInfinity1.ts, 10, 11))
50+
51+
export type Oops = 123456789123456789123456789123456789123456789123456789;
52+
>Oops : Symbol(Oops, Decl(fakeInfinity1.ts, 18, 11))
53+
54+
export const oops = 123456789123456789123456789123456789123456789123456789;
55+
>oops : Symbol(oops, Decl(fakeInfinity1.ts, 21, 12))
56+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
//// [tests/cases/compiler/fakeInfinity1.ts] ////
2+
3+
=== fakeInfinity1.ts ===
4+
// These are not actually the real infinity.
5+
export type PositiveInfinity = 1e999;
6+
>PositiveInfinity : Infinity
7+
8+
export type NegativeInfinity = -1e999;
9+
>NegativeInfinity : -Infinity
10+
>-1e999 : -Infinity
11+
>1e999 : Infinity
12+
13+
export type TypeOfInfinity = typeof Infinity;
14+
>TypeOfInfinity : number
15+
>Infinity : number
16+
17+
export type TypeOfNaN = typeof NaN;
18+
>TypeOfNaN : number
19+
>NaN : number
20+
21+
type A = 1e999;
22+
>A : Infinity
23+
24+
type B = 1e9999;
25+
>B : Infinity
26+
27+
declare let a: A;
28+
>a : Infinity
29+
30+
declare let b: B;
31+
>b : Infinity
32+
33+
a = b;
34+
>a = b : Infinity
35+
>a : Infinity
36+
>b : Infinity
37+
38+
b = a;
39+
>b = a : Infinity
40+
>b : Infinity
41+
>a : Infinity
42+
43+
a = Infinity;
44+
>a = Infinity : number
45+
>a : Infinity
46+
>Infinity : number
47+
48+
a = 1e999;
49+
>a = 1e999 : Infinity
50+
>a : Infinity
51+
>1e999 : Infinity
52+
53+
a = 1e9999;
54+
>a = 1e9999 : Infinity
55+
>a : Infinity
56+
>1e9999 : Infinity
57+
58+
export type Oops = 123456789123456789123456789123456789123456789123456789;
59+
>Oops : 1.2345678912345678e+53
60+
61+
export const oops = 123456789123456789123456789123456789123456789123456789;
62+
>oops : 1.2345678912345678e+53
63+
>123456789123456789123456789123456789123456789123456789 : 1.2345678912345678e+53
64+
+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
//// [tests/cases/compiler/fakeInfinity2.ts] ////
2+
3+
//// [fakeInfinity2.ts]
4+
export enum Foo {
5+
A = 1e999,
6+
B = -1e999,
7+
}
8+
9+
namespace X {
10+
type A = 1e999;
11+
type B = 2e999;
12+
13+
export function f(): A {
14+
throw new Error()
15+
}
16+
}
17+
18+
export const m = X.f();
19+
20+
21+
//// [fakeInfinity2.js]
22+
"use strict";
23+
Object.defineProperty(exports, "__esModule", { value: true });
24+
exports.m = exports.Foo = void 0;
25+
var Foo;
26+
(function (Foo) {
27+
Foo[Foo["A"] = Infinity] = "A";
28+
Foo[Foo["B"] = -Infinity] = "B";
29+
})(Foo || (exports.Foo = Foo = {}));
30+
var X;
31+
(function (X) {
32+
function f() {
33+
throw new Error();
34+
}
35+
X.f = f;
36+
})(X || (X = {}));
37+
exports.m = X.f();
38+
39+
40+
//// [fakeInfinity2.d.ts]
41+
export declare enum Foo {
42+
A = Infinity,
43+
B = -Infinity
44+
}
45+
export declare const m: Infinity;
46+
47+
48+
//// [DtsFileErrors]
49+
50+
51+
fakeInfinity2.d.ts(5,25): error TS2749: 'Infinity' refers to a value, but is being used as a type here. Did you mean 'typeof Infinity'?
52+
53+
54+
==== fakeInfinity2.d.ts (1 errors) ====
55+
export declare enum Foo {
56+
A = Infinity,
57+
B = -Infinity
58+
}
59+
export declare const m: Infinity;
60+
~~~~~~~~
61+
!!! error TS2749: 'Infinity' refers to a value, but is being used as a type here. Did you mean 'typeof Infinity'?
62+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
//// [tests/cases/compiler/fakeInfinity2.ts] ////
2+
3+
=== fakeInfinity2.ts ===
4+
export enum Foo {
5+
>Foo : Symbol(Foo, Decl(fakeInfinity2.ts, 0, 0))
6+
7+
A = 1e999,
8+
>A : Symbol(Foo.A, Decl(fakeInfinity2.ts, 0, 17))
9+
10+
B = -1e999,
11+
>B : Symbol(Foo.B, Decl(fakeInfinity2.ts, 1, 14))
12+
}
13+
14+
namespace X {
15+
>X : Symbol(X, Decl(fakeInfinity2.ts, 3, 1))
16+
17+
type A = 1e999;
18+
>A : Symbol(A, Decl(fakeInfinity2.ts, 5, 13))
19+
20+
type B = 2e999;
21+
>B : Symbol(B, Decl(fakeInfinity2.ts, 6, 19))
22+
23+
export function f(): A {
24+
>f : Symbol(f, Decl(fakeInfinity2.ts, 7, 19))
25+
>A : Symbol(A, Decl(fakeInfinity2.ts, 5, 13))
26+
27+
throw new Error()
28+
>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
29+
}
30+
}
31+
32+
export const m = X.f();
33+
>m : Symbol(m, Decl(fakeInfinity2.ts, 14, 12))
34+
>X.f : Symbol(X.f, Decl(fakeInfinity2.ts, 7, 19))
35+
>X : Symbol(X, Decl(fakeInfinity2.ts, 3, 1))
36+
>f : Symbol(X.f, Decl(fakeInfinity2.ts, 7, 19))
37+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
//// [tests/cases/compiler/fakeInfinity2.ts] ////
2+
3+
=== fakeInfinity2.ts ===
4+
export enum Foo {
5+
>Foo : Foo
6+
7+
A = 1e999,
8+
>A : Foo.A
9+
>1e999 : Infinity
10+
11+
B = -1e999,
12+
>B : Foo.B
13+
>-1e999 : -Infinity
14+
>1e999 : Infinity
15+
}
16+
17+
namespace X {
18+
>X : typeof X
19+
20+
type A = 1e999;
21+
>A : Infinity
22+
23+
type B = 2e999;
24+
>B : Infinity
25+
26+
export function f(): A {
27+
>f : () => Infinity
28+
29+
throw new Error()
30+
>new Error() : Error
31+
>Error : ErrorConstructor
32+
}
33+
}
34+
35+
export const m = X.f();
36+
>m : Infinity
37+
>X.f() : Infinity
38+
>X.f : () => Infinity
39+
>X : typeof X
40+
>f : () => Infinity
41+

0 commit comments

Comments
 (0)