Skip to content

Commit

Permalink
Play with "tsplus/ForceLazyArgument"
Browse files Browse the repository at this point in the history
  • Loading branch information
patroza committed Feb 3, 2023
1 parent 518a259 commit 6d7bed4
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/compiler/checker.ts
Expand Up @@ -33345,6 +33345,15 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
}
return false;
}
function isForceLazyParameterByType(type: Type): type is TypeReference {
if (type.symbol && type.symbol.declarations && type.symbol.declarations.length > 0) {
const tag = collectTsPlusTypeTags(type.symbol.declarations[0])[0];
if (tag === "tsplus/ForceLazyArgument") {
return true;
}
}
return false;
}
// TSPLUS EXTENSION END

function getMutableArrayOrTupleType(type: Type) {
Expand Down Expand Up @@ -33572,7 +33581,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
// TSPLUS EXTENTION START
const originalParamType = thisType;
let paramType = originalParamType;
if (isLazyParameterByType(originalParamType) && thisArgumentNode) {
if ((isLazyParameterByType(originalParamType) || isForceLazyParameterByType(originalParamType)) && thisArgumentNode) {
const contextFreeArgType = thisArgumentType;
if (isTypeIdenticalTo(contextFreeArgType, anyType) || isTypeIdenticalTo(contextFreeArgType, neverType)) {
return [createDiagnosticForNode(
Expand Down Expand Up @@ -33606,7 +33615,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
const originalParamType = getTypeAtPosition(signature, i);
const argType = checkExpressionWithContextualType(arg, unionIfLazy(originalParamType), /*inferenceContext*/ undefined, checkMode);
let paramType = originalParamType;
if (isLazyParameterByType(originalParamType)) {
if (isLazyParameterByType(originalParamType) || isForceLazyParameterByType(originalParamType)) {
if ((isTypeIdenticalTo(argType, anyType) || isTypeIdenticalTo(argType, neverType)) && !(checkMode & CheckMode.SkipGenericFunctions)) {
return [createDiagnosticForNode(
arg,
Expand Down

0 comments on commit 6d7bed4

Please sign in to comment.