Skip to content

Commit e1958f7

Browse files
committed
No errors for missing apparent type of bigint,symbol for any target
1 parent 6d5bf6a commit e1958f7

10 files changed

+30
-54
lines changed

src/compiler/checker.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -12298,9 +12298,9 @@ namespace ts {
1229812298
t.flags & TypeFlags.Intersection ? getApparentTypeOfIntersectionType(t as IntersectionType) :
1229912299
t.flags & TypeFlags.StringLike ? globalStringType :
1230012300
t.flags & TypeFlags.NumberLike ? globalNumberType :
12301-
t.flags & TypeFlags.BigIntLike ? getGlobalBigIntType(/*reportErrors*/ languageVersion >= ScriptTarget.ES2020) :
12301+
t.flags & TypeFlags.BigIntLike ? getGlobalBigIntType() :
1230212302
t.flags & TypeFlags.BooleanLike ? globalBooleanType :
12303-
t.flags & TypeFlags.ESSymbolLike ? getGlobalESSymbolType(/*reportErrors*/ languageVersion >= ScriptTarget.ES2015) :
12303+
t.flags & TypeFlags.ESSymbolLike ? getGlobalESSymbolType() :
1230412304
t.flags & TypeFlags.NonPrimitive ? emptyObjectType :
1230512305
t.flags & TypeFlags.Index ? keyofConstraintType :
1230612306
t.flags & TypeFlags.Unknown && !strictNullChecks ? emptyObjectType :
@@ -14026,8 +14026,8 @@ namespace ts {
1402614026
return deferredGlobalESSymbolConstructorTypeSymbol ||= getGlobalTypeSymbol("SymbolConstructor" as __String, reportErrors);
1402714027
}
1402814028

14029-
function getGlobalESSymbolType(reportErrors: boolean) {
14030-
return (deferredGlobalESSymbolType ||= getGlobalType("Symbol" as __String, /*arity*/ 0, reportErrors)) || emptyObjectType;
14029+
function getGlobalESSymbolType() {
14030+
return (deferredGlobalESSymbolType ||= getGlobalType("Symbol" as __String, /*arity*/ 0, /*reportErrors*/ false)) || emptyObjectType;
1403114031
}
1403214032

1403314033
function getGlobalPromiseType(reportErrors: boolean) {
@@ -14109,8 +14109,8 @@ namespace ts {
1410914109
return deferredGlobalAwaitedSymbol === unknownSymbol ? undefined : deferredGlobalAwaitedSymbol;
1411014110
}
1411114111

14112-
function getGlobalBigIntType(reportErrors: boolean) {
14113-
return (deferredGlobalBigIntType ||= getGlobalType("BigInt" as __String, /*arity*/ 0, reportErrors)) || emptyObjectType;
14112+
function getGlobalBigIntType() {
14113+
return (deferredGlobalBigIntType ||= getGlobalType("BigInt" as __String, /*arity*/ 0, /*reportErrors*/ false)) || emptyObjectType;
1411414114
}
1411514115

1411614116
/**
@@ -18553,7 +18553,7 @@ namespace ts {
1855318553
if ((globalStringType === source && stringType === target) ||
1855418554
(globalNumberType === source && numberType === target) ||
1855518555
(globalBooleanType === source && booleanType === target) ||
18556-
(getGlobalESSymbolType(/*reportErrors*/ false) === source && esSymbolType === target)) {
18556+
(getGlobalESSymbolType() === source && esSymbolType === target)) {
1855718557
reportError(Diagnostics._0_is_a_primitive_but_1_is_a_wrapper_object_Prefer_using_0_when_possible, targetType, sourceType);
1855818558
}
1855918559
}

src/lib/es5.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ interface ObjectConstructor {
210210
* Prevents the modification of existing property attributes and values, and prevents the addition of new properties.
211211
* @param o Object on which to lock the attributes.
212212
*/
213-
freeze<T extends {[idx: string]: U | null | undefined | object}, U extends string | number | boolean | symbol>(o: T): Readonly<T>;
213+
freeze<T extends {[idx: string]: U | null | undefined | object}, U extends string | bigint | number | boolean | symbol>(o: T): Readonly<T>;
214214

215215
/**
216216
* Prevents the modification of existing property attributes and values, and prevents the addition of new properties.

tests/baselines/reference/bigintMissingES2020.errors.txt

-12
This file was deleted.

tests/baselines/reference/bigintMissingESNext.errors.txt

-12
This file was deleted.

tests/baselines/reference/circularContextualReturnType.types

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,19 @@
33

44
Object.freeze({
55
>Object.freeze({ foo() { return Object.freeze('a'); },}) : Readonly<{ foo(): string; }>
6-
>Object.freeze : { <T>(a: T[]): readonly T[]; <T extends Function>(f: T): T; <T extends { [idx: string]: object | U | null | undefined; }, U extends string | number | boolean | symbol>(o: T): Readonly<T>; <T>(o: T): Readonly<T>; }
6+
>Object.freeze : { <T>(a: T[]): readonly T[]; <T extends Function>(f: T): T; <T extends { [idx: string]: object | U | null | undefined; }, U extends string | number | bigint | boolean | symbol>(o: T): Readonly<T>; <T>(o: T): Readonly<T>; }
77
>Object : ObjectConstructor
8-
>freeze : { <T>(a: T[]): readonly T[]; <T extends Function>(f: T): T; <T extends { [idx: string]: object | U | null | undefined; }, U extends string | number | boolean | symbol>(o: T): Readonly<T>; <T>(o: T): Readonly<T>; }
8+
>freeze : { <T>(a: T[]): readonly T[]; <T extends Function>(f: T): T; <T extends { [idx: string]: object | U | null | undefined; }, U extends string | number | bigint | boolean | symbol>(o: T): Readonly<T>; <T>(o: T): Readonly<T>; }
99
>{ foo() { return Object.freeze('a'); },} : { foo(): string; }
1010

1111
foo() {
1212
>foo : () => string
1313

1414
return Object.freeze('a');
1515
>Object.freeze('a') : string
16-
>Object.freeze : { <T>(a: T[]): readonly T[]; <T extends Function>(f: T): T; <T extends { [idx: string]: object | U | null | undefined; }, U extends string | number | boolean | symbol>(o: T): Readonly<T>; <T>(o: T): Readonly<T>; }
16+
>Object.freeze : { <T>(a: T[]): readonly T[]; <T extends Function>(f: T): T; <T extends { [idx: string]: object | U | null | undefined; }, U extends string | number | bigint | boolean | symbol>(o: T): Readonly<T>; <T>(o: T): Readonly<T>; }
1717
>Object : ObjectConstructor
18-
>freeze : { <T>(a: T[]): readonly T[]; <T extends Function>(f: T): T; <T extends { [idx: string]: object | U | null | undefined; }, U extends string | number | boolean | symbol>(o: T): Readonly<T>; <T>(o: T): Readonly<T>; }
18+
>freeze : { <T>(a: T[]): readonly T[]; <T extends Function>(f: T): T; <T extends { [idx: string]: object | U | null | undefined; }, U extends string | number | bigint | boolean | symbol>(o: T): Readonly<T>; <T>(o: T): Readonly<T>; }
1919
>'a' : "a"
2020

2121
},

tests/baselines/reference/contextualSignatureInObjectFreeze.types

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33

44
Object.freeze({
55
>Object.freeze({ f: function () { }}) : Readonly<{ f: () => void; }>
6-
>Object.freeze : { <T>(a: T[]): readonly T[]; <T extends Function>(f: T): T; <T extends { [idx: string]: object | U; }, U extends string | number | boolean | symbol>(o: T): Readonly<T>; <T>(o: T): Readonly<T>; }
6+
>Object.freeze : { <T>(a: T[]): readonly T[]; <T extends Function>(f: T): T; <T extends { [idx: string]: object | U; }, U extends string | number | bigint | boolean | symbol>(o: T): Readonly<T>; <T>(o: T): Readonly<T>; }
77
>Object : ObjectConstructor
8-
>freeze : { <T>(a: T[]): readonly T[]; <T extends Function>(f: T): T; <T extends { [idx: string]: object | U; }, U extends string | number | boolean | symbol>(o: T): Readonly<T>; <T>(o: T): Readonly<T>; }
8+
>freeze : { <T>(a: T[]): readonly T[]; <T extends Function>(f: T): T; <T extends { [idx: string]: object | U; }, U extends string | number | bigint | boolean | symbol>(o: T): Readonly<T>; <T>(o: T): Readonly<T>; }
99
>{ f: function () { }} : { f: () => void; }
1010

1111
f: function () { }

tests/baselines/reference/jsEnumTagOnObjectFrozen.types

+2-2
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ cbThing(type => {
4949
const Thing = Object.freeze({
5050
>Thing : Readonly<{ a: "thing"; b: "chill"; }>
5151
>Object.freeze({ a: "thing", b: "chill"}) : Readonly<{ a: "thing"; b: "chill"; }>
52-
>Object.freeze : { <T>(a: T[]): readonly T[]; <T extends Function>(f: T): T; <T extends { [idx: string]: object | U; }, U extends string | number | boolean | symbol>(o: T): Readonly<T>; <T>(o: T): Readonly<T>; }
52+
>Object.freeze : { <T>(a: T[]): readonly T[]; <T extends Function>(f: T): T; <T extends { [idx: string]: object | U; }, U extends string | number | bigint | boolean | symbol>(o: T): Readonly<T>; <T>(o: T): Readonly<T>; }
5353
>Object : ObjectConstructor
54-
>freeze : { <T>(a: T[]): readonly T[]; <T extends Function>(f: T): T; <T extends { [idx: string]: object | U; }, U extends string | number | boolean | symbol>(o: T): Readonly<T>; <T>(o: T): Readonly<T>; }
54+
>freeze : { <T>(a: T[]): readonly T[]; <T extends Function>(f: T): T; <T extends { [idx: string]: object | U; }, U extends string | number | bigint | boolean | symbol>(o: T): Readonly<T>; <T>(o: T): Readonly<T>; }
5555
>{ a: "thing", b: "chill"} : { a: "thing"; b: "chill"; }
5656

5757
a: "thing",

tests/baselines/reference/keyofAndIndexedAccess.types

+2-2
Original file line numberDiff line numberDiff line change
@@ -1876,9 +1876,9 @@ class SampleClass<P> {
18761876
>this : this
18771877
>props : Readonly<P>
18781878
>Object.freeze(props) : Readonly<P>
1879-
>Object.freeze : { <T>(a: T[]): readonly T[]; <T extends Function>(f: T): T; <T extends { [idx: string]: object | U | null | undefined; }, U extends string | number | boolean | symbol>(o: T): Readonly<T>; <T>(o: T): Readonly<T>; }
1879+
>Object.freeze : { <T>(a: T[]): readonly T[]; <T extends Function>(f: T): T; <T extends { [idx: string]: object | U | null | undefined; }, U extends string | number | bigint | boolean | symbol>(o: T): Readonly<T>; <T>(o: T): Readonly<T>; }
18801880
>Object : ObjectConstructor
1881-
>freeze : { <T>(a: T[]): readonly T[]; <T extends Function>(f: T): T; <T extends { [idx: string]: object | U | null | undefined; }, U extends string | number | boolean | symbol>(o: T): Readonly<T>; <T>(o: T): Readonly<T>; }
1881+
>freeze : { <T>(a: T[]): readonly T[]; <T extends Function>(f: T): T; <T extends { [idx: string]: object | U | null | undefined; }, U extends string | number | bigint | boolean | symbol>(o: T): Readonly<T>; <T>(o: T): Readonly<T>; }
18821882
>props : P
18831883
}
18841884
}

tests/baselines/reference/objectFreeze.types

+8-8
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
const f = Object.freeze(function foo(a: number, b: string) { return false; });
33
>f : (a: number, b: string) => false
44
>Object.freeze(function foo(a: number, b: string) { return false; }) : (a: number, b: string) => false
5-
>Object.freeze : { <T>(a: T[]): readonly T[]; <T extends Function>(f: T): T; <T extends { [idx: string]: object | U; }, U extends string | number | boolean | symbol>(o: T): Readonly<T>; <T>(o: T): Readonly<T>; }
5+
>Object.freeze : { <T>(a: T[]): readonly T[]; <T extends Function>(f: T): T; <T extends { [idx: string]: object | U; }, U extends string | number | bigint | boolean | symbol>(o: T): Readonly<T>; <T>(o: T): Readonly<T>; }
66
>Object : ObjectConstructor
7-
>freeze : { <T>(a: T[]): readonly T[]; <T extends Function>(f: T): T; <T extends { [idx: string]: object | U; }, U extends string | number | boolean | symbol>(o: T): Readonly<T>; <T>(o: T): Readonly<T>; }
7+
>freeze : { <T>(a: T[]): readonly T[]; <T extends Function>(f: T): T; <T extends { [idx: string]: object | U; }, U extends string | number | bigint | boolean | symbol>(o: T): Readonly<T>; <T>(o: T): Readonly<T>; }
88
>function foo(a: number, b: string) { return false; } : (a: number, b: string) => false
99
>foo : (a: number, b: string) => false
1010
>a : number
@@ -26,9 +26,9 @@ class C { constructor(a: number) { } }
2626
const c = Object.freeze(C);
2727
>c : typeof C
2828
>Object.freeze(C) : typeof C
29-
>Object.freeze : { <T>(a: T[]): readonly T[]; <T extends Function>(f: T): T; <T extends { [idx: string]: object | U; }, U extends string | number | boolean | symbol>(o: T): Readonly<T>; <T>(o: T): Readonly<T>; }
29+
>Object.freeze : { <T>(a: T[]): readonly T[]; <T extends Function>(f: T): T; <T extends { [idx: string]: object | U; }, U extends string | number | bigint | boolean | symbol>(o: T): Readonly<T>; <T>(o: T): Readonly<T>; }
3030
>Object : ObjectConstructor
31-
>freeze : { <T>(a: T[]): readonly T[]; <T extends Function>(f: T): T; <T extends { [idx: string]: object | U; }, U extends string | number | boolean | symbol>(o: T): Readonly<T>; <T>(o: T): Readonly<T>; }
31+
>freeze : { <T>(a: T[]): readonly T[]; <T extends Function>(f: T): T; <T extends { [idx: string]: object | U; }, U extends string | number | bigint | boolean | symbol>(o: T): Readonly<T>; <T>(o: T): Readonly<T>; }
3232
>C : typeof C
3333

3434
new c(1);
@@ -39,9 +39,9 @@ new c(1);
3939
const a = Object.freeze([1, 2, 3]);
4040
>a : readonly number[]
4141
>Object.freeze([1, 2, 3]) : readonly number[]
42-
>Object.freeze : { <T>(a: T[]): readonly T[]; <T extends Function>(f: T): T; <T extends { [idx: string]: object | U; }, U extends string | number | boolean | symbol>(o: T): Readonly<T>; <T>(o: T): Readonly<T>; }
42+
>Object.freeze : { <T>(a: T[]): readonly T[]; <T extends Function>(f: T): T; <T extends { [idx: string]: object | U; }, U extends string | number | bigint | boolean | symbol>(o: T): Readonly<T>; <T>(o: T): Readonly<T>; }
4343
>Object : ObjectConstructor
44-
>freeze : { <T>(a: T[]): readonly T[]; <T extends Function>(f: T): T; <T extends { [idx: string]: object | U; }, U extends string | number | boolean | symbol>(o: T): Readonly<T>; <T>(o: T): Readonly<T>; }
44+
>freeze : { <T>(a: T[]): readonly T[]; <T extends Function>(f: T): T; <T extends { [idx: string]: object | U; }, U extends string | number | bigint | boolean | symbol>(o: T): Readonly<T>; <T>(o: T): Readonly<T>; }
4545
>[1, 2, 3] : number[]
4646
>1 : 1
4747
>2 : 2
@@ -62,9 +62,9 @@ a[0] = a[2].toString();
6262
const o = Object.freeze({ a: 1, b: "string", c: true });
6363
>o : Readonly<{ a: 1; b: "string"; c: true; }>
6464
>Object.freeze({ a: 1, b: "string", c: true }) : Readonly<{ a: 1; b: "string"; c: true; }>
65-
>Object.freeze : { <T>(a: T[]): readonly T[]; <T extends Function>(f: T): T; <T extends { [idx: string]: object | U; }, U extends string | number | boolean | symbol>(o: T): Readonly<T>; <T>(o: T): Readonly<T>; }
65+
>Object.freeze : { <T>(a: T[]): readonly T[]; <T extends Function>(f: T): T; <T extends { [idx: string]: object | U; }, U extends string | number | bigint | boolean | symbol>(o: T): Readonly<T>; <T>(o: T): Readonly<T>; }
6666
>Object : ObjectConstructor
67-
>freeze : { <T>(a: T[]): readonly T[]; <T extends Function>(f: T): T; <T extends { [idx: string]: object | U; }, U extends string | number | boolean | symbol>(o: T): Readonly<T>; <T>(o: T): Readonly<T>; }
67+
>freeze : { <T>(a: T[]): readonly T[]; <T extends Function>(f: T): T; <T extends { [idx: string]: object | U; }, U extends string | number | bigint | boolean | symbol>(o: T): Readonly<T>; <T>(o: T): Readonly<T>; }
6868
>{ a: 1, b: "string", c: true } : { a: 1; b: "string"; c: true; }
6969
>a : 1
7070
>1 : 1

tests/baselines/reference/objectFromEntries.types

+4-4
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ const o3 = Object.fromEntries(new Map([[Symbol("key"), "value"]]));
4343
const frozenArray = Object.freeze([['a', 1], ['b', 2], ['c', 3]]);
4444
>frozenArray : readonly (string | number)[][]
4545
>Object.freeze([['a', 1], ['b', 2], ['c', 3]]) : readonly (string | number)[][]
46-
>Object.freeze : { <T>(a: T[]): readonly T[]; <T extends Function>(f: T): T; <T extends { [idx: string]: object | U; }, U extends string | number | boolean | symbol>(o: T): Readonly<T>; <T>(o: T): Readonly<T>; }
46+
>Object.freeze : { <T>(a: T[]): readonly T[]; <T extends Function>(f: T): T; <T extends { [idx: string]: object | U; }, U extends string | number | bigint | boolean | symbol>(o: T): Readonly<T>; <T>(o: T): Readonly<T>; }
4747
>Object : ObjectConstructor
48-
>freeze : { <T>(a: T[]): readonly T[]; <T extends Function>(f: T): T; <T extends { [idx: string]: object | U; }, U extends string | number | boolean | symbol>(o: T): Readonly<T>; <T>(o: T): Readonly<T>; }
48+
>freeze : { <T>(a: T[]): readonly T[]; <T extends Function>(f: T): T; <T extends { [idx: string]: object | U; }, U extends string | number | bigint | boolean | symbol>(o: T): Readonly<T>; <T>(o: T): Readonly<T>; }
4949
>[['a', 1], ['b', 2], ['c', 3]] : (string | number)[][]
5050
>['a', 1] : (string | number)[]
5151
>'a' : "a"
@@ -68,9 +68,9 @@ const o4 = Object.fromEntries(frozenArray);
6868
const frozenArray2: readonly [string, number][] = Object.freeze([['a', 1], ['b', 2], ['c', 3]]);
6969
>frozenArray2 : readonly [string, number][]
7070
>Object.freeze([['a', 1], ['b', 2], ['c', 3]]) : readonly [string, number][]
71-
>Object.freeze : { <T>(a: T[]): readonly T[]; <T extends Function>(f: T): T; <T extends { [idx: string]: object | U; }, U extends string | number | boolean | symbol>(o: T): Readonly<T>; <T>(o: T): Readonly<T>; }
71+
>Object.freeze : { <T>(a: T[]): readonly T[]; <T extends Function>(f: T): T; <T extends { [idx: string]: object | U; }, U extends string | number | bigint | boolean | symbol>(o: T): Readonly<T>; <T>(o: T): Readonly<T>; }
7272
>Object : ObjectConstructor
73-
>freeze : { <T>(a: T[]): readonly T[]; <T extends Function>(f: T): T; <T extends { [idx: string]: object | U; }, U extends string | number | boolean | symbol>(o: T): Readonly<T>; <T>(o: T): Readonly<T>; }
73+
>freeze : { <T>(a: T[]): readonly T[]; <T extends Function>(f: T): T; <T extends { [idx: string]: object | U; }, U extends string | number | bigint | boolean | symbol>(o: T): Readonly<T>; <T>(o: T): Readonly<T>; }
7474
>[['a', 1], ['b', 2], ['c', 3]] : [string, number][]
7575
>['a', 1] : [string, number]
7676
>'a' : "a"

0 commit comments

Comments
 (0)