mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-04-17 01:49:41 -05:00
Handle composite signatures in isResolvingReturnTypeOfSignature (#55165)
This commit is contained in:
@@ -14888,8 +14888,9 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
||||
return getReturnTypeOfTypeTag(declaration);
|
||||
}
|
||||
|
||||
function isResolvingReturnTypeOfSignature(signature: Signature) {
|
||||
return !signature.resolvedReturnType && findResolutionCycleStartIndex(signature, TypeSystemPropertyName.ResolvedReturnType) >= 0;
|
||||
function isResolvingReturnTypeOfSignature(signature: Signature): boolean {
|
||||
return signature.compositeSignatures && some(signature.compositeSignatures, isResolvingReturnTypeOfSignature) ||
|
||||
!signature.resolvedReturnType && findResolutionCycleStartIndex(signature, TypeSystemPropertyName.ResolvedReturnType) >= 0;
|
||||
}
|
||||
|
||||
function getRestTypeOfSignature(signature: Signature): Type {
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
//// [tests/cases/compiler/compositeContextualSignature.ts] ////
|
||||
|
||||
=== compositeContextualSignature.ts ===
|
||||
// Repro from #55145
|
||||
|
||||
function f<T extends any[]>(v: ReadonlyArray<T>) { }
|
||||
>f : Symbol(f, Decl(compositeContextualSignature.ts, 0, 0))
|
||||
>T : Symbol(T, Decl(compositeContextualSignature.ts, 2, 11))
|
||||
>v : Symbol(v, Decl(compositeContextualSignature.ts, 2, 28))
|
||||
>ReadonlyArray : Symbol(ReadonlyArray, Decl(lib.es5.d.ts, --, --))
|
||||
>T : Symbol(T, Decl(compositeContextualSignature.ts, 2, 11))
|
||||
|
||||
f([
|
||||
>f : Symbol(f, Decl(compositeContextualSignature.ts, 0, 0))
|
||||
|
||||
[
|
||||
undefined,
|
||||
>undefined : Symbol(undefined)
|
||||
|
||||
() => { },
|
||||
],
|
||||
[
|
||||
1,
|
||||
() => {
|
||||
console.log('Hello')
|
||||
>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
|
||||
>console : Symbol(console, Decl(lib.dom.d.ts, --, --))
|
||||
>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
|
||||
|
||||
},
|
||||
],
|
||||
]);
|
||||
|
||||
44
tests/baselines/reference/compositeContextualSignature.types
Normal file
44
tests/baselines/reference/compositeContextualSignature.types
Normal file
@@ -0,0 +1,44 @@
|
||||
//// [tests/cases/compiler/compositeContextualSignature.ts] ////
|
||||
|
||||
=== compositeContextualSignature.ts ===
|
||||
// Repro from #55145
|
||||
|
||||
function f<T extends any[]>(v: ReadonlyArray<T>) { }
|
||||
>f : <T extends any[]>(v: ReadonlyArray<T>) => void
|
||||
>v : readonly T[]
|
||||
|
||||
f([
|
||||
>f([ [ undefined, () => { }, ], [ 1, () => { console.log('Hello') }, ],]) : void
|
||||
>f : <T extends any[]>(v: readonly T[]) => void
|
||||
>[ [ undefined, () => { }, ], [ 1, () => { console.log('Hello') }, ],] : (((() => void) | undefined)[] | (number | (() => void))[])[]
|
||||
|
||||
[
|
||||
>[ undefined, () => { }, ] : ((() => void) | undefined)[]
|
||||
|
||||
undefined,
|
||||
>undefined : undefined
|
||||
|
||||
() => { },
|
||||
>() => { } : () => void
|
||||
|
||||
],
|
||||
[
|
||||
>[ 1, () => { console.log('Hello') }, ] : (number | (() => void))[]
|
||||
|
||||
1,
|
||||
>1 : 1
|
||||
|
||||
() => {
|
||||
>() => { console.log('Hello') } : () => void
|
||||
|
||||
console.log('Hello')
|
||||
>console.log('Hello') : void
|
||||
>console.log : (...data: any[]) => void
|
||||
>console : Console
|
||||
>log : (...data: any[]) => void
|
||||
>'Hello' : "Hello"
|
||||
|
||||
},
|
||||
],
|
||||
]);
|
||||
|
||||
19
tests/cases/compiler/compositeContextualSignature.ts
Normal file
19
tests/cases/compiler/compositeContextualSignature.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
// @strict: true
|
||||
// @noEmit: true
|
||||
|
||||
// Repro from #55145
|
||||
|
||||
function f<T extends any[]>(v: ReadonlyArray<T>) { }
|
||||
|
||||
f([
|
||||
[
|
||||
undefined,
|
||||
() => { },
|
||||
],
|
||||
[
|
||||
1,
|
||||
() => {
|
||||
console.log('Hello')
|
||||
},
|
||||
],
|
||||
]);
|
||||
Reference in New Issue
Block a user