Skip to content

Exception in quickInfo with conditional types #21611

Closed
@rbuckton

Description

@rbuckton

TypeScript Version: 2.8.0-dev (master)

Code

interface Awaiters<T> {
    0: T extends PromiseLike<any> ? never : T;
    1: Awaiter<T, 0>;
    [depth: number]: Awaiters<T>[keyof Awaiters<T>];
}
type Awaiter<T, Depth extends number> = T extends PromiseLike<infer U> ? Awaiters<U>[Depth] : never;
type Awaited<T> = Awaiters<T>[keyof Awaiters<T>];

interface BadPromise {
    then(onfulfilled: (value: BadPromise ) => void): any;
}

type T1 = Awaited<BadPromise>;

Repro steps:

  1. Open a new TS file in VS Code with the above source text.
  2. Ensure the VS Code Output window is open with the TypeScript extension output active.
  3. Hover over T1 above.

Expected behavior:

Quick Info reports type T1 = never;

Actual behavior:

Exception in quickInfo:

[Error  - 3:19:57 PM] 'quickinfo' request failed with error.
Error processing request. Maximum call stack size exceeded
RangeError: Maximum call stack size exceeded
    at getSymbolLinks (c:\dev\TypeScript\built\local\tsserver.js:21829:32)
    at instantiateSymbol (c:\dev\TypeScript\built\local\tsserver.js:27969:25)
    at instantiateList (c:\dev\TypeScript\built\local\tsserver.js:27867:34)
    at instantiateSignature (c:\dev\TypeScript\built\local\tsserver.js:27963:165)
    at getBaseSignature (c:\dev\TypeScript\built\local\tsserver.js:26524:24)
    at inferFromSignatures (c:\dev\TypeScript\built\local\tsserver.js:30358:97)
    at inferFromObjectTypes (c:\dev\TypeScript\built\local\tsserver.js:30336:21)
    at inferFromTypes (c:\dev\TypeScript\built\local\tsserver.js:30278:29)
    at inferFromProperties (c:\dev\TypeScript\built\local\tsserver.js:30347:25)
    at inferFromObjectTypes (c:\dev\TypeScript\built\local\tsserver.js:30335:21)
    at inferFromTypes (c:\dev\TypeScript\built\local\tsserver.js:30278:29)
    at inferTypes (c:\dev\TypeScript\built\local\tsserver.js:30129:13)
    at getConditionalType (c:\dev\TypeScript\built\local\tsserver.js:27548:17)
    at instantiateConditionalType (c:\dev\TypeScript\built\local\tsserver.js:28086:20)
    at c:\dev\TypeScript\built\local\tsserver.js:28080:76
    at mapType (c:\dev\TypeScript\built\local\tsserver.js:30926:25)
    at getConditionalTypeInstantiation (c:\dev\TypeScript\built\local\tsserver.js:28080:28)
    at instantiateType (c:\dev\TypeScript\built\local\tsserver.js:28124:28)
    at instantiateList (c:\dev\TypeScript\built\local\tsserver.js:27872:41)
    at instantiateTypes (c:\dev\TypeScript\built\local\tsserver.js:27881:20)
    at instantiateType (c:\dev\TypeScript\built\local\tsserver.js:28109:36)
    at instantiateIndexInfo (c:\dev\TypeScript\built\local\tsserver.js:28137:44)
    at resolveObjectTypeMembers (c:\dev\TypeScript\built\local\tsserver.js:25386:35)
    at resolveTypeReferenceMembers (c:\dev\TypeScript\built\local\tsserver.js:25419:13)
    at resolveStructuredTypeMembers (c:\dev\TypeScript\built\local\tsserver.js:25762:25)
    at getPropertyOfType (c:\dev\TypeScript\built\local\tsserver.js:26085:32)
    at getPropertyTypeForIndexType (c:\dev\TypeScript\built\local\tsserver.js:27363:28)
    at getIndexedAccessType (c:\dev\TypeScript\built\local\tsserver.js:27503:20)
    at instantiateType (c:\dev\TypeScript\built\local\tsserver.js:28121:28)
    at getConditionalType (c:\dev\TypeScript\built\local\tsserver.js:27558:24)
    at instantiateConditionalType (c:\dev\TypeScript\built\local\tsserver.js:28086:20)
    at c:\dev\TypeScript\built\local\tsserver.js:28080:76
    ...
    at mapType (c:\dev\TypeScript\built\local\tsserver.js:30926:25)
    at getConditionalTypeInstantiation (c:\dev\TypeScript\built\local\tsserver.js:28080:28)
    at instantiateType (c:\dev\TypeScript\built\local\tsserver.js:28124:28)
    at instantiateList (c:\dev\TypeScript\built\local\tsserver.js:27872:41)
    at instantiateTypes (c:\dev\TypeScript\built\local\tsserver.js:27881:20)
    at instantiateType (c:\dev\TypeScript\built\local\tsserver.js:28109:36)
    at instantiateIndexInfo (c:\dev\TypeScript\built\local\tsserver.js:28137:44)
    at resolveObjectTypeMembers (c:\dev\TypeScript\built\local\tsserver.js:25386:35)
    at resolveTypeReferenceMembers (c:\dev\TypeScript\built\local\tsserver.js:25419:13)
    at resolveStructuredTypeMembers (c:\dev\TypeScript\built\local\tsserver.js:25762:25)
    at getPropertyOfType (c:\dev\TypeScript\built\local\tsserver.js:26085:32)
    at getPropertyTypeForIndexType (c:\dev\TypeScript\built\local\tsserver.js:27363:28)
    at getIndexedAccessType (c:\dev\TypeScript\built\local\tsserver.js:27503:20)
    at instantiateType (c:\dev\TypeScript\built\local\tsserver.js:28121:28)
    at getConditionalType (c:\dev\TypeScript\built\local\tsserver.js:27558:24)
    at instantiateConditionalType (c:\dev\TypeScript\built\local\tsserver.js:28086:20)
    at c:\dev\TypeScript\built\local\tsserver.js:28080:76

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptFixedA PR has been merged for this issue

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions