Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🤖 Pick PR #49104 (No errors on apparent type of bigin...) into release-4.7 #49135

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 7 additions & 7 deletions src/compiler/checker.ts
Expand Up @@ -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 :
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
}

/**
Expand Down Expand Up @@ -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);
}
}
Expand Down
12 changes: 0 additions & 12 deletions tests/baselines/reference/bigintMissingES2020.errors.txt

This file was deleted.

4 changes: 2 additions & 2 deletions tests/baselines/reference/bigintMissingES2020.js
Expand Up @@ -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
2 changes: 1 addition & 1 deletion tests/baselines/reference/bigintMissingES2020.symbols
Expand Up @@ -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

2 changes: 1 addition & 1 deletion tests/baselines/reference/bigintMissingES2020.types
Expand Up @@ -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

12 changes: 0 additions & 12 deletions tests/baselines/reference/bigintMissingESNext.errors.txt

This file was deleted.

4 changes: 2 additions & 2 deletions tests/baselines/reference/bigintMissingESNext.js
Expand Up @@ -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
2 changes: 1 addition & 1 deletion tests/baselines/reference/bigintMissingESNext.symbols
Expand Up @@ -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

2 changes: 1 addition & 1 deletion tests/baselines/reference/bigintMissingESNext.types
Expand Up @@ -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

13 changes: 13 additions & 0 deletions tests/baselines/reference/contextualSignatureInObjectFreeze.js
@@ -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))

})

16 changes: 16 additions & 0 deletions tests/baselines/reference/contextualSignatureInObjectFreeze.types
@@ -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

})

7 changes: 7 additions & 0 deletions tests/cases/compiler/contextualSignatureInObjectFreeze.ts
@@ -0,0 +1,7 @@
// #49101
// @target: es2020
// @lib: es2019

Object.freeze({
f: function () { }
})
2 changes: 1 addition & 1 deletion tests/cases/conformance/es2020/bigintMissingES2020.ts
Expand Up @@ -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
2 changes: 1 addition & 1 deletion tests/cases/conformance/es2020/bigintMissingESNext.ts
Expand Up @@ -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