Skip to content

Commit b48868d

Browse files
committed
Merge branch 'main' into import-assertions-module-nodenext
2 parents 2c5b9a9 + 56f8107 commit b48868d

13 files changed

+225
-6
lines changed

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scripts/open-cherry-pick-pr.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ async function main() {
3333

3434
const inputPR = (await gh.pulls.get({ pull_number: +process.env.SOURCE_ISSUE, owner: "microsoft", repo: "TypeScript" })).data;
3535
let remoteName = "origin";
36-
if (inputPR.base.repo.git_url !== `git:github.com/microsoft/TypeScript`) {
36+
if (inputPR.base.repo.git_url !== `git:github.com/microsoft/TypeScript` && inputPR.base.repo.git_url !== `git://github.com/microsoft/TypeScript`) {
3737
runSequence([
38-
["git", ["remote", "add", "nonlocal", inputPR.base.repo.git_url]]
38+
["git", ["remote", "add", "nonlocal", inputPR.base.repo.git_url.replace(/^git:(?:\/\/)?/, "https://")]]
3939
]);
4040
remoteName = "nonlocal";
4141
}

src/compiler/checker.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14153,6 +14153,7 @@ namespace ts {
1415314153
// We ignore 'never' types in unions
1415414154
if (!(flags & TypeFlags.Never)) {
1415514155
includes |= flags & TypeFlags.IncludesMask;
14156+
if (flags & TypeFlags.Instantiable) includes |= TypeFlags.IncludesInstantiable;
1415614157
if (type === wildcardType) includes |= TypeFlags.IncludesWildcard;
1415714158
if (!strictNullChecks && flags & TypeFlags.Nullable) {
1415814159
if (!(getObjectFlags(type) & ObjectFlags.ContainsWideningType)) includes |= TypeFlags.IncludesNonWideningType;
@@ -19046,7 +19047,7 @@ namespace ts {
1904619047
originalErrorInfo = undefined;
1904719048
}
1904819049
}
19049-
else if (isGenericMappedType(target)) {
19050+
else if (isGenericMappedType(target) && relation !== identityRelation) {
1905019051
// Check if source type `S` is related to target type `{ [P in Q]: T }` or `{ [P in Q as R]: T}`.
1905119052
const keysRemapped = !!target.declaration.nameType;
1905219053
const templateType = getTemplateTypeFromMappedType(target);

src/compiler/types.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5187,8 +5187,6 @@ namespace ts {
51875187
// 'Narrowable' types are types where narrowing actually narrows.
51885188
// This *should* be every type other than null, undefined, void, and never
51895189
Narrowable = Any | Unknown | StructuredOrInstantiable | StringLike | NumberLike | BigIntLike | BooleanLike | ESSymbol | UniqueESSymbol | NonPrimitive,
5190-
/* @internal */
5191-
NotPrimitiveUnion = Any | Unknown | Enum | Void | Never | Object | Intersection | Instantiable,
51925190
// The following flags are aggregated during union and intersection type construction
51935191
/* @internal */
51945192
IncludesMask = Any | Unknown | Primitive | Never | Object | Union | Intersection | NonPrimitive | TemplateLiteral,
@@ -5201,6 +5199,10 @@ namespace ts {
52015199
IncludesWildcard = IndexedAccess,
52025200
/* @internal */
52035201
IncludesEmptyObject = Conditional,
5202+
/* @internal */
5203+
IncludesInstantiable = Substitution,
5204+
/* @internal */
5205+
NotPrimitiveUnion = Any | Unknown | Enum | Void | Never | Object | Intersection | IncludesInstantiable,
52045206
}
52055207

52065208
export type DestructuringPattern = BindingPattern | ObjectLiteralExpression | ArrayLiteralExpression;
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
tests/cases/compiler/noExcessiveStackDepthError.ts(13,9): error TS2403: Subsequent variable declarations must have the same type. Variable 'x' must be of type 'FindConditions<any>', but here has type 'FindConditions<Entity>'.
2+
3+
4+
==== tests/cases/compiler/noExcessiveStackDepthError.ts (1 errors) ====
5+
// Repro from #46631
6+
7+
interface FindOperator<T> {
8+
foo: T;
9+
}
10+
11+
type FindConditions<T> = {
12+
[P in keyof T]?: FindConditions<T[P]> | FindOperator<FindConditions<T[P]>>;
13+
};
14+
15+
function foo<Entity>() {
16+
var x: FindConditions<any>;
17+
var x: FindConditions<Entity>; // Excessive stack depth error not expected here
18+
~
19+
!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'x' must be of type 'FindConditions<any>', but here has type 'FindConditions<Entity>'.
20+
!!! related TS6203 tests/cases/compiler/noExcessiveStackDepthError.ts:12:9: 'x' was also declared here.
21+
}
22+
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
//// [noExcessiveStackDepthError.ts]
2+
// Repro from #46631
3+
4+
interface FindOperator<T> {
5+
foo: T;
6+
}
7+
8+
type FindConditions<T> = {
9+
[P in keyof T]?: FindConditions<T[P]> | FindOperator<FindConditions<T[P]>>;
10+
};
11+
12+
function foo<Entity>() {
13+
var x: FindConditions<any>;
14+
var x: FindConditions<Entity>; // Excessive stack depth error not expected here
15+
}
16+
17+
18+
//// [noExcessiveStackDepthError.js]
19+
"use strict";
20+
// Repro from #46631
21+
function foo() {
22+
var x;
23+
var x; // Excessive stack depth error not expected here
24+
}
25+
26+
27+
//// [noExcessiveStackDepthError.d.ts]
28+
interface FindOperator<T> {
29+
foo: T;
30+
}
31+
declare type FindConditions<T> = {
32+
[P in keyof T]?: FindConditions<T[P]> | FindOperator<FindConditions<T[P]>>;
33+
};
34+
declare function foo<Entity>(): void;
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
=== tests/cases/compiler/noExcessiveStackDepthError.ts ===
2+
// Repro from #46631
3+
4+
interface FindOperator<T> {
5+
>FindOperator : Symbol(FindOperator, Decl(noExcessiveStackDepthError.ts, 0, 0))
6+
>T : Symbol(T, Decl(noExcessiveStackDepthError.ts, 2, 23))
7+
8+
foo: T;
9+
>foo : Symbol(FindOperator.foo, Decl(noExcessiveStackDepthError.ts, 2, 27))
10+
>T : Symbol(T, Decl(noExcessiveStackDepthError.ts, 2, 23))
11+
}
12+
13+
type FindConditions<T> = {
14+
>FindConditions : Symbol(FindConditions, Decl(noExcessiveStackDepthError.ts, 4, 1))
15+
>T : Symbol(T, Decl(noExcessiveStackDepthError.ts, 6, 20))
16+
17+
[P in keyof T]?: FindConditions<T[P]> | FindOperator<FindConditions<T[P]>>;
18+
>P : Symbol(P, Decl(noExcessiveStackDepthError.ts, 7, 5))
19+
>T : Symbol(T, Decl(noExcessiveStackDepthError.ts, 6, 20))
20+
>FindConditions : Symbol(FindConditions, Decl(noExcessiveStackDepthError.ts, 4, 1))
21+
>T : Symbol(T, Decl(noExcessiveStackDepthError.ts, 6, 20))
22+
>P : Symbol(P, Decl(noExcessiveStackDepthError.ts, 7, 5))
23+
>FindOperator : Symbol(FindOperator, Decl(noExcessiveStackDepthError.ts, 0, 0))
24+
>FindConditions : Symbol(FindConditions, Decl(noExcessiveStackDepthError.ts, 4, 1))
25+
>T : Symbol(T, Decl(noExcessiveStackDepthError.ts, 6, 20))
26+
>P : Symbol(P, Decl(noExcessiveStackDepthError.ts, 7, 5))
27+
28+
};
29+
30+
function foo<Entity>() {
31+
>foo : Symbol(foo, Decl(noExcessiveStackDepthError.ts, 8, 2))
32+
>Entity : Symbol(Entity, Decl(noExcessiveStackDepthError.ts, 10, 13))
33+
34+
var x: FindConditions<any>;
35+
>x : Symbol(x, Decl(noExcessiveStackDepthError.ts, 11, 7), Decl(noExcessiveStackDepthError.ts, 12, 7))
36+
>FindConditions : Symbol(FindConditions, Decl(noExcessiveStackDepthError.ts, 4, 1))
37+
38+
var x: FindConditions<Entity>; // Excessive stack depth error not expected here
39+
>x : Symbol(x, Decl(noExcessiveStackDepthError.ts, 11, 7), Decl(noExcessiveStackDepthError.ts, 12, 7))
40+
>FindConditions : Symbol(FindConditions, Decl(noExcessiveStackDepthError.ts, 4, 1))
41+
>Entity : Symbol(Entity, Decl(noExcessiveStackDepthError.ts, 10, 13))
42+
}
43+
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
=== tests/cases/compiler/noExcessiveStackDepthError.ts ===
2+
// Repro from #46631
3+
4+
interface FindOperator<T> {
5+
foo: T;
6+
>foo : T
7+
}
8+
9+
type FindConditions<T> = {
10+
>FindConditions : FindConditions<T>
11+
12+
[P in keyof T]?: FindConditions<T[P]> | FindOperator<FindConditions<T[P]>>;
13+
};
14+
15+
function foo<Entity>() {
16+
>foo : <Entity>() => void
17+
18+
var x: FindConditions<any>;
19+
>x : FindConditions<any>
20+
21+
var x: FindConditions<Entity>; // Excessive stack depth error not expected here
22+
>x : FindConditions<any>
23+
}
24+
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
//// [primitiveUnionDetection.ts]
2+
// Repro from #46624
3+
4+
type Kind = "one" | "two" | "three";
5+
6+
declare function getInterfaceFromString<T extends Kind>(options?: { type?: T } & { type?: Kind }): T;
7+
8+
const result = getInterfaceFromString({ type: 'two' });
9+
10+
11+
//// [primitiveUnionDetection.js]
12+
"use strict";
13+
// Repro from #46624
14+
var result = getInterfaceFromString({ type: 'two' });
15+
16+
17+
//// [primitiveUnionDetection.d.ts]
18+
declare type Kind = "one" | "two" | "three";
19+
declare function getInterfaceFromString<T extends Kind>(options?: {
20+
type?: T;
21+
} & {
22+
type?: Kind;
23+
}): T;
24+
declare const result: "two";
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
=== tests/cases/compiler/primitiveUnionDetection.ts ===
2+
// Repro from #46624
3+
4+
type Kind = "one" | "two" | "three";
5+
>Kind : Symbol(Kind, Decl(primitiveUnionDetection.ts, 0, 0))
6+
7+
declare function getInterfaceFromString<T extends Kind>(options?: { type?: T } & { type?: Kind }): T;
8+
>getInterfaceFromString : Symbol(getInterfaceFromString, Decl(primitiveUnionDetection.ts, 2, 36))
9+
>T : Symbol(T, Decl(primitiveUnionDetection.ts, 4, 40))
10+
>Kind : Symbol(Kind, Decl(primitiveUnionDetection.ts, 0, 0))
11+
>options : Symbol(options, Decl(primitiveUnionDetection.ts, 4, 56))
12+
>type : Symbol(type, Decl(primitiveUnionDetection.ts, 4, 67))
13+
>T : Symbol(T, Decl(primitiveUnionDetection.ts, 4, 40))
14+
>type : Symbol(type, Decl(primitiveUnionDetection.ts, 4, 82))
15+
>Kind : Symbol(Kind, Decl(primitiveUnionDetection.ts, 0, 0))
16+
>T : Symbol(T, Decl(primitiveUnionDetection.ts, 4, 40))
17+
18+
const result = getInterfaceFromString({ type: 'two' });
19+
>result : Symbol(result, Decl(primitiveUnionDetection.ts, 6, 5))
20+
>getInterfaceFromString : Symbol(getInterfaceFromString, Decl(primitiveUnionDetection.ts, 2, 36))
21+
>type : Symbol(type, Decl(primitiveUnionDetection.ts, 6, 39))
22+

0 commit comments

Comments
 (0)