π Search Terms
type provided should not be a non-generic 'promise'-like
π Version & Regression Information
- This is a crash
- This is the behavior in every version I tried: v5.2.2 and v5.3.2
β― Playground Link
Playground link
Note: Because this is a crash, the playground looks broken. The browser console has the stack trace.
π» Code
// @strict
type NotPromise<T> = T extends Thennable<unknown>
? T
: T extends PromiseLike<unknown>
? never
: T;
type Receiver<T> = (value: NotPromise<T>) => void;
class Thennable<T> {
then(a: Receiver<T>) {}
private handleResolve<TResult>(
result: NotPromise<TResult> | Thennable<NotPromise<TResult>>,
resolve: Receiver<TResult>,
) {
if (result instanceof Thennable) {
// Error: Debug Failure. False expression: type provided should not be a non-generic 'promise'-like.
this.resolvePromise(result, resolve);
}
}
private resolvePromise<TResult>(
result: Thennable<TResult>,
resolve: Receiver<TResult>,
) {}
}
π Actual behavior
Error: Debug Failure. False expression: type provided should not be a non-generic 'promise'-like.
at createAwaitedTypeIfNeeded (/test-ts-debug-assert-promise-like/node_modules/typescript/lib/tsc.js:76671:11)
at getAwaitedType (/test-ts-debug-assert-promise-like/node_modules/typescript/lib/tsc.js:76676:27)
at getAwaitedTypeOfPromise (/test-ts-debug-assert-promise-like/node_modules/typescript/lib/tsc.js:76554:28)
at maybeAddMissingAwaitInfo (/test-ts-debug-assert-promise-like/node_modules/typescript/lib/tsc.js:70872:13)
at getSignatureApplicabilityError (/test-ts-debug-assert-promise-like/node_modules/typescript/lib/tsc.js:70837:11)
at resolveCall (/test-ts-debug-assert-promise-like/node_modules/typescript/lib/tsc.js:71232:25)
at resolveCallExpression (/test-ts-debug-assert-promise-like/node_modules/typescript/lib/tsc.js:71633:12)
at resolveSignature (/test-ts-debug-assert-promise-like/node_modules/typescript/lib/tsc.js:72037:16)
at getResolvedSignature (/test-ts-debug-assert-promise-like/node_modules/typescript/lib/tsc.js:72059:18)
at checkCallExpression (/test-ts-debug-assert-promise-like/node_modules/typescript/lib/tsc.js:72171:23)
at the node this.resolvePromise(result, resolve);
π Expected behavior
No crash.
Additional information about the issue
Found this when migrating to ts.transpileModule. As far as I can tell it's triggered by 2 conditions, which all have to be true:
strictFunctionTypes: true
- The type
PromiseLike must not exist, e.g. by using noLib: true
π Search Terms
type provided should not be a non-generic 'promise'-like
π Version & Regression Information
β― Playground Link
Playground link
Note: Because this is a crash, the playground looks broken. The browser console has the stack trace.
π» Code
π Actual behavior
at the node
this.resolvePromise(result, resolve);π Expected behavior
No crash.
Additional information about the issue
Found this when migrating to
ts.transpileModule. As far as I can tell it's triggered by 2 conditions, which all have to be true:strictFunctionTypes: truePromiseLikemust not exist, e.g. by usingnoLib: true