Skip to content

Commit 6d7bed4

Browse files
committed
Play with "tsplus/ForceLazyArgument"
1 parent 518a259 commit 6d7bed4

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/compiler/checker.ts

+11-2
Original file line numberDiff line numberDiff line change
@@ -33345,6 +33345,15 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
3334533345
}
3334633346
return false;
3334733347
}
33348+
function isForceLazyParameterByType(type: Type): type is TypeReference {
33349+
if (type.symbol && type.symbol.declarations && type.symbol.declarations.length > 0) {
33350+
const tag = collectTsPlusTypeTags(type.symbol.declarations[0])[0];
33351+
if (tag === "tsplus/ForceLazyArgument") {
33352+
return true;
33353+
}
33354+
}
33355+
return false;
33356+
}
3334833357
// TSPLUS EXTENSION END
3334933358

3335033359
function getMutableArrayOrTupleType(type: Type) {
@@ -33572,7 +33581,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
3357233581
// TSPLUS EXTENTION START
3357333582
const originalParamType = thisType;
3357433583
let paramType = originalParamType;
33575-
if (isLazyParameterByType(originalParamType) && thisArgumentNode) {
33584+
if ((isLazyParameterByType(originalParamType) || isForceLazyParameterByType(originalParamType)) && thisArgumentNode) {
3357633585
const contextFreeArgType = thisArgumentType;
3357733586
if (isTypeIdenticalTo(contextFreeArgType, anyType) || isTypeIdenticalTo(contextFreeArgType, neverType)) {
3357833587
return [createDiagnosticForNode(
@@ -33606,7 +33615,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
3360633615
const originalParamType = getTypeAtPosition(signature, i);
3360733616
const argType = checkExpressionWithContextualType(arg, unionIfLazy(originalParamType), /*inferenceContext*/ undefined, checkMode);
3360833617
let paramType = originalParamType;
33609-
if (isLazyParameterByType(originalParamType)) {
33618+
if (isLazyParameterByType(originalParamType) || isForceLazyParameterByType(originalParamType)) {
3361033619
if ((isTypeIdenticalTo(argType, anyType) || isTypeIdenticalTo(argType, neverType)) && !(checkMode & CheckMode.SkipGenericFunctions)) {
3361133620
return [createDiagnosticForNode(
3361233621
arg,

0 commit comments

Comments
 (0)