mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Component commits:4c6e802772Remove bigint from Object.freeze in es5.d.ts `BigInt` isn't resolved whenever `lib < es2020`, but it's not an error when `target < es2020`. I have a few ideas for improving this situation but for the RC I'm going to remove `bigint` from Object.freeze's signature.6d5bf6a5eeUpdate other baselinese1958f7a23No errors for missing apparent type of bigint,symbol for any target86fc8dbd0bUpdate test text Co-authored-by: Nathan Shively-Sanders <nathansa@microsoft.com>
This commit is contained in:
co-authored by
Nathan Shively-Sanders
parent
7bd7163ac4
commit
77b83f1106
@@ -12296,9 +12296,9 @@ namespace ts {
|
||||
t.flags & TypeFlags.Intersection ? getApparentTypeOfIntersectionType(t as IntersectionType) :
|
||||
t.flags & TypeFlags.StringLike ? globalStringType :
|
||||
t.flags & TypeFlags.NumberLike ? globalNumberType :
|
||||
t.flags & TypeFlags.BigIntLike ? getGlobalBigIntType(/*reportErrors*/ languageVersion >= ScriptTarget.ES2020) :
|
||||
t.flags & TypeFlags.BigIntLike ? getGlobalBigIntType() :
|
||||
t.flags & TypeFlags.BooleanLike ? globalBooleanType :
|
||||
t.flags & TypeFlags.ESSymbolLike ? getGlobalESSymbolType(/*reportErrors*/ languageVersion >= ScriptTarget.ES2015) :
|
||||
t.flags & TypeFlags.ESSymbolLike ? getGlobalESSymbolType() :
|
||||
t.flags & TypeFlags.NonPrimitive ? emptyObjectType :
|
||||
t.flags & TypeFlags.Index ? keyofConstraintType :
|
||||
t.flags & TypeFlags.Unknown && !strictNullChecks ? emptyObjectType :
|
||||
@@ -14024,8 +14024,8 @@ namespace ts {
|
||||
return deferredGlobalESSymbolConstructorTypeSymbol ||= getGlobalTypeSymbol("SymbolConstructor" as __String, reportErrors);
|
||||
}
|
||||
|
||||
function getGlobalESSymbolType(reportErrors: boolean) {
|
||||
return (deferredGlobalESSymbolType ||= getGlobalType("Symbol" as __String, /*arity*/ 0, reportErrors)) || emptyObjectType;
|
||||
function getGlobalESSymbolType() {
|
||||
return (deferredGlobalESSymbolType ||= getGlobalType("Symbol" as __String, /*arity*/ 0, /*reportErrors*/ false)) || emptyObjectType;
|
||||
}
|
||||
|
||||
function getGlobalPromiseType(reportErrors: boolean) {
|
||||
@@ -14107,8 +14107,8 @@ namespace ts {
|
||||
return deferredGlobalAwaitedSymbol === unknownSymbol ? undefined : deferredGlobalAwaitedSymbol;
|
||||
}
|
||||
|
||||
function getGlobalBigIntType(reportErrors: boolean) {
|
||||
return (deferredGlobalBigIntType ||= getGlobalType("BigInt" as __String, /*arity*/ 0, reportErrors)) || emptyObjectType;
|
||||
function getGlobalBigIntType() {
|
||||
return (deferredGlobalBigIntType ||= getGlobalType("BigInt" as __String, /*arity*/ 0, /*reportErrors*/ false)) || emptyObjectType;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -18551,7 +18551,7 @@ namespace ts {
|
||||
if ((globalStringType === source && stringType === target) ||
|
||||
(globalNumberType === source && numberType === target) ||
|
||||
(globalBooleanType === source && booleanType === target) ||
|
||||
(getGlobalESSymbolType(/*reportErrors*/ false) === source && esSymbolType === target)) {
|
||||
(getGlobalESSymbolType() === source && esSymbolType === target)) {
|
||||
reportError(Diagnostics._0_is_a_primitive_but_1_is_a_wrapper_object_Prefer_using_0_when_possible, targetType, sourceType);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
error TS2318: Cannot find global type 'BigInt'.
|
||||
|
||||
|
||||
!!! error TS2318: Cannot find global type 'BigInt'.
|
||||
==== tests/cases/conformance/es2020/bigintMissingES2020.ts (0 errors) ====
|
||||
declare function test<A, B extends A>(): void;
|
||||
|
||||
test<{t?: string}, object>();
|
||||
test<{t?: string}, bigint>();
|
||||
|
||||
// should have global error when bigint is used but ES2020 lib is not present
|
||||
|
||||
@@ -4,10 +4,10 @@ declare function test<A, B extends A>(): void;
|
||||
test<{t?: string}, object>();
|
||||
test<{t?: string}, bigint>();
|
||||
|
||||
// should have global error when bigint is used but ES2020 lib is not present
|
||||
// no error when bigint is used even when ES2020 lib is not present
|
||||
|
||||
|
||||
//// [bigintMissingES2020.js]
|
||||
test();
|
||||
test();
|
||||
// should have global error when bigint is used but ES2020 lib is not present
|
||||
// no error when bigint is used even when ES2020 lib is not present
|
||||
|
||||
@@ -13,5 +13,5 @@ test<{t?: string}, bigint>();
|
||||
>test : Symbol(test, Decl(bigintMissingES2020.ts, 0, 0))
|
||||
>t : Symbol(t, Decl(bigintMissingES2020.ts, 3, 6))
|
||||
|
||||
// should have global error when bigint is used but ES2020 lib is not present
|
||||
// no error when bigint is used even when ES2020 lib is not present
|
||||
|
||||
|
||||
@@ -12,5 +12,5 @@ test<{t?: string}, bigint>();
|
||||
>test : <A, B extends A>() => void
|
||||
>t : string
|
||||
|
||||
// should have global error when bigint is used but ES2020 lib is not present
|
||||
// no error when bigint is used even when ES2020 lib is not present
|
||||
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
error TS2318: Cannot find global type 'BigInt'.
|
||||
|
||||
|
||||
!!! error TS2318: Cannot find global type 'BigInt'.
|
||||
==== tests/cases/conformance/es2020/bigintMissingESNext.ts (0 errors) ====
|
||||
declare function test<A, B extends A>(): void;
|
||||
|
||||
test<{t?: string}, object>();
|
||||
test<{t?: string}, bigint>();
|
||||
|
||||
// should have global error when bigint is used but ES2020 lib is not present
|
||||
|
||||
@@ -4,10 +4,10 @@ declare function test<A, B extends A>(): void;
|
||||
test<{t?: string}, object>();
|
||||
test<{t?: string}, bigint>();
|
||||
|
||||
// should have global error when bigint is used but ES2020 lib is not present
|
||||
// no error when bigint is used even when ES2020 lib is not present
|
||||
|
||||
|
||||
//// [bigintMissingESNext.js]
|
||||
test();
|
||||
test();
|
||||
// should have global error when bigint is used but ES2020 lib is not present
|
||||
// no error when bigint is used even when ES2020 lib is not present
|
||||
|
||||
@@ -13,5 +13,5 @@ test<{t?: string}, bigint>();
|
||||
>test : Symbol(test, Decl(bigintMissingESNext.ts, 0, 0))
|
||||
>t : Symbol(t, Decl(bigintMissingESNext.ts, 3, 6))
|
||||
|
||||
// should have global error when bigint is used but ES2020 lib is not present
|
||||
// no error when bigint is used even when ES2020 lib is not present
|
||||
|
||||
|
||||
@@ -12,5 +12,5 @@ test<{t?: string}, bigint>();
|
||||
>test : <A, B extends A>() => void
|
||||
>t : string
|
||||
|
||||
// should have global error when bigint is used but ES2020 lib is not present
|
||||
// no error when bigint is used even when ES2020 lib is not present
|
||||
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
//// [contextualSignatureInObjectFreeze.ts]
|
||||
// #49101
|
||||
|
||||
Object.freeze({
|
||||
f: function () { }
|
||||
})
|
||||
|
||||
|
||||
//// [contextualSignatureInObjectFreeze.js]
|
||||
// #49101
|
||||
Object.freeze({
|
||||
f: function () { }
|
||||
});
|
||||
@@ -0,0 +1,13 @@
|
||||
=== tests/cases/compiler/contextualSignatureInObjectFreeze.ts ===
|
||||
// #49101
|
||||
|
||||
Object.freeze({
|
||||
>Object.freeze : Symbol(ObjectConstructor.freeze, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
||||
>Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
||||
>freeze : Symbol(ObjectConstructor.freeze, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
||||
|
||||
f: function () { }
|
||||
>f : Symbol(f, Decl(contextualSignatureInObjectFreeze.ts, 2, 15))
|
||||
|
||||
})
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
=== tests/cases/compiler/contextualSignatureInObjectFreeze.ts ===
|
||||
// #49101
|
||||
|
||||
Object.freeze({
|
||||
>Object.freeze({ f: function () { }}) : Readonly<{ f: () => void; }>
|
||||
>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>; }
|
||||
>Object : ObjectConstructor
|
||||
>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>; }
|
||||
>{ f: function () { }} : { f: () => void; }
|
||||
|
||||
f: function () { }
|
||||
>f : () => void
|
||||
>function () { } : () => void
|
||||
|
||||
})
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
// #49101
|
||||
// @target: es2020
|
||||
// @lib: es2019
|
||||
|
||||
Object.freeze({
|
||||
f: function () { }
|
||||
})
|
||||
@@ -5,4 +5,4 @@ declare function test<A, B extends A>(): void;
|
||||
test<{t?: string}, object>();
|
||||
test<{t?: string}, bigint>();
|
||||
|
||||
// should have global error when bigint is used but ES2020 lib is not present
|
||||
// no error when bigint is used even when ES2020 lib is not present
|
||||
|
||||
@@ -5,4 +5,4 @@ declare function test<A, B extends A>(): void;
|
||||
test<{t?: string}, object>();
|
||||
test<{t?: string}, bigint>();
|
||||
|
||||
// should have global error when bigint is used but ES2020 lib is not present
|
||||
// no error when bigint is used even when ES2020 lib is not present
|
||||
|
||||
Reference in New Issue
Block a user