Skip to content

Commit 90b7d94

Browse files
committed
Merge branch 'main' into intl-numberformat
2 parents a6261f9 + be20dbb commit 90b7d94

File tree

82 files changed

+1341
-384
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+1341
-384
lines changed

package-lock.json

Lines changed: 288 additions & 288 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/compiler/checker.ts

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19107,6 +19107,12 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
1910719107
}
1910819108

1910919109
function getESSymbolLikeTypeForNode(node: Node) {
19110+
if (isInJSFile(node) && isJSDocTypeExpression(node)) {
19111+
const host = getJSDocHost(node);
19112+
if (host) {
19113+
node = getSingleVariableOfVariableStatement(host) || host;
19114+
}
19115+
}
1911019116
if (isValidESSymbolDeclaration(node)) {
1911119117
const symbol = isCommonJsExportPropertyAssignment(node) ? getSymbolOfNode((node as BinaryExpression).left) : getSymbolOfNode(node);
1911219118
if (symbol) {
@@ -22313,7 +22319,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
2231322319
// This is a carve-out in comparability to essentially forbid comparing a type parameter
2231422320
// with another type parameter unless one extends the other. (Remember: comparability is mostly bidirectional!)
2231522321
let constraint = getConstraintOfTypeParameter(source);
22316-
if (constraint && hasNonCircularBaseConstraint(source)) {
22322+
if (constraint) {
2231722323
while (constraint && someType(constraint, c => !!(c.flags & TypeFlags.TypeParameter))) {
2231822324
if (result = isRelatedTo(constraint, target, RecursionFlags.Source, /*reportErrors*/ false)) {
2231922325
return result;
@@ -25538,6 +25544,9 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
2553825544
}
2553925545
else {
2554025546
source = getReducedType(source);
25547+
if (isGenericMappedType(source) && isGenericMappedType(target)) {
25548+
invokeOnce(source, target, inferFromGenericMappedTypes);
25549+
}
2554125550
if (!(priority & InferencePriority.NoConstraints && source.flags & (TypeFlags.Intersection | TypeFlags.Instantiable))) {
2554225551
const apparentSource = getApparentType(source);
2554325552
// getApparentType can return _any_ type, since an indexed access or conditional may simplify to any other type.
@@ -25575,6 +25584,19 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
2557525584
priority = savePriority;
2557625585
}
2557725586

25587+
// Ensure an inference action is performed only once for the given source and target types.
25588+
// This includes two things:
25589+
// Avoiding inferring between the same pair of source and target types,
25590+
// and avoiding circularly inferring between source and target types.
25591+
// For an example of the last, consider if we are inferring between source type
25592+
// `type Deep<T> = { next: Deep<Deep<T>> }` and target type `type Loop<U> = { next: Loop<U> }`.
25593+
// We would then infer between the types of the `next` property: `Deep<Deep<T>>` = `{ next: Deep<Deep<Deep<T>>> }` and `Loop<U>` = `{ next: Loop<U> }`.
25594+
// We will then infer again between the types of the `next` property:
25595+
// `Deep<Deep<Deep<T>>>` and `Loop<U>`, and so on, such that we would be forever inferring
25596+
// between instantiations of the same types `Deep` and `Loop`.
25597+
// In particular, we would be inferring from increasingly deep instantiations of `Deep` to `Loop`,
25598+
// such that we would go on inferring forever, even though we would never infer
25599+
// between the same pair of types.
2557825600
function invokeOnce<Source extends Type, Target extends Type>(source: Source, target: Target, action: (source: Source, target: Target) => void) {
2557925601
const key = source.id + "," + target.id;
2558025602
const status = visited && visited.get(key);
@@ -25882,6 +25904,16 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
2588225904
}
2588325905
}
2588425906

25907+
function inferFromGenericMappedTypes(source: MappedType, target: MappedType) {
25908+
// The source and target types are generic types { [P in S]: X } and { [P in T]: Y }, so we infer
25909+
// from S to T and from X to Y.
25910+
inferFromTypes(getConstraintTypeFromMappedType(source), getConstraintTypeFromMappedType(target));
25911+
inferFromTypes(getTemplateTypeFromMappedType(source), getTemplateTypeFromMappedType(target));
25912+
const sourceNameType = getNameTypeFromMappedType(source);
25913+
const targetNameType = getNameTypeFromMappedType(target);
25914+
if (sourceNameType && targetNameType) inferFromTypes(sourceNameType, targetNameType);
25915+
}
25916+
2588525917
function inferFromObjectTypes(source: Type, target: Type) {
2588625918
if (
2588725919
getObjectFlags(source) & ObjectFlags.Reference && getObjectFlags(target) & ObjectFlags.Reference && (
@@ -25893,13 +25925,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
2589325925
return;
2589425926
}
2589525927
if (isGenericMappedType(source) && isGenericMappedType(target)) {
25896-
// The source and target types are generic types { [P in S]: X } and { [P in T]: Y }, so we infer
25897-
// from S to T and from X to Y.
25898-
inferFromTypes(getConstraintTypeFromMappedType(source), getConstraintTypeFromMappedType(target));
25899-
inferFromTypes(getTemplateTypeFromMappedType(source), getTemplateTypeFromMappedType(target));
25900-
const sourceNameType = getNameTypeFromMappedType(source);
25901-
const targetNameType = getNameTypeFromMappedType(target);
25902-
if (sourceNameType && targetNameType) inferFromTypes(sourceNameType, targetNameType);
25928+
inferFromGenericMappedTypes(source, target);
2590325929
}
2590425930
if (getObjectFlags(target) & ObjectFlags.Mapped && !(target as MappedType).declaration.nameType) {
2590525931
const constraintType = getConstraintTypeFromMappedType(target as MappedType);

src/compiler/commandLineParser.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,11 @@ const libEntries: [string, string][] = [
162162
// Host only
163163
["dom", "lib.dom.d.ts"],
164164
["dom.iterable", "lib.dom.iterable.d.ts"],
165+
["dom.asynciterable", "lib.dom.asynciterable.d.ts"],
165166
["webworker", "lib.webworker.d.ts"],
166167
["webworker.importscripts", "lib.webworker.importscripts.d.ts"],
167168
["webworker.iterable", "lib.webworker.iterable.d.ts"],
169+
["webworker.asynciterable", "lib.webworker.asynciterable.d.ts"],
168170
["scripthost", "lib.scripthost.d.ts"],
169171
// ES2015 Or ESNext By-feature options
170172
["es2015.core", "lib.es2015.core.d.ts"],
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/////////////////////////////
2+
/// Window Async Iterable APIs
3+
/////////////////////////////
4+
5+
interface FileSystemDirectoryHandle {
6+
[Symbol.asyncIterator](): AsyncIterableIterator<[string, FileSystemHandle]>;
7+
entries(): AsyncIterableIterator<[string, FileSystemHandle]>;
8+
keys(): AsyncIterableIterator<string>;
9+
values(): AsyncIterableIterator<FileSystemHandle>;
10+
}

src/lib/es2018.full.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
/// <reference lib="webworker.importscripts" />
44
/// <reference lib="scripthost" />
55
/// <reference lib="dom.iterable" />
6+
/// <reference lib="dom.asynciterable" />

src/lib/es2019.full.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
/// <reference lib="webworker.importscripts" />
44
/// <reference lib="scripthost" />
55
/// <reference lib="dom.iterable" />
6+
/// <reference lib="dom.asynciterable" />

src/lib/es2020.full.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
/// <reference lib="webworker.importscripts" />
44
/// <reference lib="scripthost" />
55
/// <reference lib="dom.iterable" />
6+
/// <reference lib="dom.asynciterable" />

src/lib/es2021.full.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
/// <reference lib="webworker.importscripts" />
44
/// <reference lib="scripthost" />
55
/// <reference lib="dom.iterable" />
6+
/// <reference lib="dom.asynciterable" />

src/lib/es2022.full.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
/// <reference lib="webworker.importscripts" />
44
/// <reference lib="scripthost" />
55
/// <reference lib="dom.iterable" />
6+
/// <reference lib="dom.asynciterable" />

src/lib/es2023.full.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
/// <reference lib="webworker.importscripts" />
44
/// <reference lib="scripthost" />
55
/// <reference lib="dom.iterable" />
6+
/// <reference lib="dom.asynciterable" />

0 commit comments

Comments
 (0)