Skip to content

Commit 0474160

Browse files
committed
Play with "tsplus/ForceLazyArgument"
1 parent 7adeb0a commit 0474160

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
@@ -33777,6 +33777,15 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
3377733777
}
3377833778
return false;
3377933779
}
33780+
function isForceLazyParameterByType(type: Type): type is TypeReference {
33781+
if (type.symbol && type.symbol.declarations && type.symbol.declarations.length > 0) {
33782+
const tag = collectTsPlusTypeTags(type.symbol.declarations[0])[0];
33783+
if (tag === "tsplus/ForceLazyArgument") {
33784+
return true;
33785+
}
33786+
}
33787+
return false;
33788+
}
3378033789
// TSPLUS EXTENSION END
3378133790

3378233791
function getMutableArrayOrTupleType(type: Type) {
@@ -34013,7 +34022,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
3401334022
// TSPLUS EXTENTION START
3401434023
const originalParamType = thisType;
3401534024
let paramType = originalParamType;
34016-
if (isLazyParameterByType(originalParamType) && thisArgumentNode) {
34025+
if ((isLazyParameterByType(originalParamType) || isForceLazyParameterByType(originalParamType)) && thisArgumentNode) {
3401734026
const contextFreeArgType = thisArgumentType;
3401834027
if (isTypeIdenticalTo(contextFreeArgType, anyType) || isTypeIdenticalTo(contextFreeArgType, neverType)) {
3401934028
return [createDiagnosticForNode(
@@ -34047,7 +34056,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
3404734056
const originalParamType = getTypeAtPosition(signature, i);
3404834057
const argType = checkExpressionWithContextualType(arg, unionIfLazy(originalParamType), /*inferenceContext*/ undefined, checkMode);
3404934058
let paramType = originalParamType;
34050-
if (isLazyParameterByType(originalParamType)) {
34059+
if (isLazyParameterByType(originalParamType) || isForceLazyParameterByType(originalParamType)) {
3405134060
if ((isTypeIdenticalTo(argType, anyType) || isTypeIdenticalTo(argType, neverType)) && !(checkMode & CheckMode.SkipGenericFunctions)) {
3405234061
return [createDiagnosticForNode(
3405334062
arg,

0 commit comments

Comments
 (0)