Skip to content

Commit a6fb1a3

Browse files
committed
Play with "tsplus/ForceLazyArgument"
1 parent 9a7c0d1 commit a6fb1a3

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/compiler/checker.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33386,6 +33386,15 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
3338633386
}
3338733387
return false;
3338833388
}
33389+
function isForceLazyParameterByType(type: Type): type is TypeReference {
33390+
if (type.symbol && type.symbol.declarations && type.symbol.declarations.length > 0) {
33391+
const tag = collectTsPlusTypeTags(type.symbol.declarations[0])[0];
33392+
if (tag === "tsplus/ForceLazyArgument") {
33393+
return true;
33394+
}
33395+
}
33396+
return false;
33397+
}
3338933398
// TSPLUS EXTENSION END
3339033399

3339133400
function getMutableArrayOrTupleType(type: Type) {
@@ -33613,7 +33622,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
3361333622
// TSPLUS EXTENTION START
3361433623
const originalParamType = thisType;
3361533624
let paramType = originalParamType;
33616-
if (isLazyParameterByType(originalParamType) && thisArgumentNode) {
33625+
if ((isLazyParameterByType(originalParamType) || isForceLazyParameterByType(originalParamType)) && thisArgumentNode) {
3361733626
const contextFreeArgType = thisArgumentType;
3361833627
if (isTypeIdenticalTo(contextFreeArgType, anyType) || isTypeIdenticalTo(contextFreeArgType, neverType)) {
3361933628
return [createDiagnosticForNode(
@@ -33647,7 +33656,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
3364733656
const originalParamType = getTypeAtPosition(signature, i);
3364833657
const argType = checkExpressionWithContextualType(arg, unionIfLazy(originalParamType), /*inferenceContext*/ undefined, checkMode);
3364933658
let paramType = originalParamType;
33650-
if (isLazyParameterByType(originalParamType)) {
33659+
if (isLazyParameterByType(originalParamType) || isForceLazyParameterByType(originalParamType)) {
3365133660
if ((isTypeIdenticalTo(argType, anyType) || isTypeIdenticalTo(argType, neverType)) && !(checkMode & CheckMode.SkipGenericFunctions)) {
3365233661
return [createDiagnosticForNode(
3365333662
arg,

0 commit comments

Comments
 (0)