remove support for conditional expressions
This commit is contained in:
Родитель
c076dda4e8
Коммит
156d52bef4
|
@ -543,7 +543,6 @@ function createBinder(): (file: SourceFile, options: CompilerOptions) => void {
|
|||
var preSwitchCaseFlow: FlowNode | undefined;
|
||||
var activeLabelList: ActiveLabel | undefined;
|
||||
var hasExplicitReturn: boolean;
|
||||
var inReturnStatement: boolean;
|
||||
var hasFlowEffects: boolean;
|
||||
|
||||
// state used for emit helpers
|
||||
|
@ -623,7 +622,6 @@ function createBinder(): (file: SourceFile, options: CompilerOptions) => void {
|
|||
currentExceptionTarget = undefined;
|
||||
activeLabelList = undefined;
|
||||
hasExplicitReturn = false;
|
||||
inReturnStatement = false;
|
||||
hasFlowEffects = false;
|
||||
inAssignmentPattern = false;
|
||||
emitFlags = NodeFlags.None;
|
||||
|
@ -1573,10 +1571,7 @@ function createBinder(): (file: SourceFile, options: CompilerOptions) => void {
|
|||
}
|
||||
|
||||
function bindReturnOrThrow(node: ReturnStatement | ThrowStatement): void {
|
||||
const oldInReturnStatement = inReturnStatement;
|
||||
inReturnStatement = true;
|
||||
bind(node.expression);
|
||||
inReturnStatement = oldInReturnStatement;
|
||||
if (node.kind === SyntaxKind.ReturnStatement) {
|
||||
hasExplicitReturn = true;
|
||||
if (currentReturnTarget) {
|
||||
|
@ -2021,16 +2016,10 @@ function createBinder(): (file: SourceFile, options: CompilerOptions) => void {
|
|||
hasFlowEffects = false;
|
||||
bindCondition(node.condition, trueLabel, falseLabel);
|
||||
currentFlow = finishFlowLabel(trueLabel);
|
||||
if (inReturnStatement) {
|
||||
node.flowNodeWhenTrue = currentFlow;
|
||||
}
|
||||
bind(node.questionToken);
|
||||
bind(node.whenTrue);
|
||||
addAntecedent(postExpressionLabel, currentFlow);
|
||||
currentFlow = finishFlowLabel(falseLabel);
|
||||
if (inReturnStatement) {
|
||||
node.flowNodeWhenFalse = currentFlow;
|
||||
}
|
||||
bind(node.colonToken);
|
||||
bind(node.whenFalse);
|
||||
addAntecedent(postExpressionLabel, currentFlow);
|
||||
|
|
|
@ -45644,12 +45644,6 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
|||
): void {
|
||||
const functionFlags = getFunctionFlags(container);
|
||||
const unwrappedReturnType = unwrapReturnType(returnType, functionFlags) ?? returnType;
|
||||
if (expr) {
|
||||
const unwrappedExpr = skipParentheses(expr, /*excludeJSDocTypeAssertions*/ true);
|
||||
if (isConditionalExpression(unwrappedExpr)) {
|
||||
return checkConditionalReturnExpression(container, returnType, node, unwrappedExpr);
|
||||
}
|
||||
}
|
||||
|
||||
const exprType = expr ? checkExpressionCached(expr) : undefinedType;
|
||||
const unwrappedExprType = functionFlags & FunctionFlags.Async
|
||||
|
@ -45684,26 +45678,8 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
|||
return;
|
||||
}
|
||||
|
||||
// There are two cases for obtaining a position in the control-flow graph on which references will be analyzed:
|
||||
// - When the return expression is defined, and it is one of the two branches of a conditional expression, then the position is the expression itself:
|
||||
// `function foo(...) {
|
||||
// return cond ? |expr| : ...
|
||||
// }`
|
||||
// - When the return expression is undefined, or it is defined and it is not one of the branches of a conditional expression, then the position is the return statement itself:
|
||||
// `function foo(...) {
|
||||
// |return expr;|
|
||||
// }`
|
||||
// or
|
||||
// `function foo(...) {
|
||||
// |return;|
|
||||
// }`
|
||||
let narrowPosition: Node = node;
|
||||
let narrowFlowNode = node.flowNode;
|
||||
if (expr && isConditionalExpression(expr.parent)) {
|
||||
narrowFlowNode = expr.parent.whenTrue === expr ? expr.parent.flowNodeWhenTrue : expr.parent.flowNodeWhenFalse;
|
||||
narrowPosition = expr;
|
||||
}
|
||||
|
||||
const narrowPosition: Node = node;
|
||||
const narrowFlowNode = node.flowNode;
|
||||
if (!narrowFlowNode) {
|
||||
checkTypeAssignableToAndOptionallyElaborate(unwrappedExprType, unwrappedReturnType, errorNode, expr);
|
||||
return;
|
||||
|
@ -45757,17 +45733,6 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
|||
checkTypeAssignableToAndOptionallyElaborate(narrowedUnwrappedExprType, narrowedReturnType, errorNode, expr);
|
||||
}
|
||||
|
||||
function checkConditionalReturnExpression(
|
||||
container: SignatureDeclaration,
|
||||
returnType: Type,
|
||||
node: ReturnStatement,
|
||||
expr: ConditionalExpression,
|
||||
): void {
|
||||
checkExpression(expr.condition);
|
||||
checkReturnStatementExpression(container, returnType, node, expr.whenTrue);
|
||||
checkReturnStatementExpression(container, returnType, node, expr.whenFalse);
|
||||
}
|
||||
|
||||
// Narrowable type parameters are type parameters that:
|
||||
// (1) have a union type constraint;
|
||||
// (2) are used as the type of a single parameter in the function, and nothing else
|
||||
|
|
|
@ -3481,8 +3481,6 @@ export function createNodeFactory(flags: NodeFactoryFlags, baseFactory: BaseNode
|
|||
propagateChildFlags(node.whenTrue) |
|
||||
propagateChildFlags(node.colonToken) |
|
||||
propagateChildFlags(node.whenFalse);
|
||||
node.flowNodeWhenFalse = undefined;
|
||||
node.flowNodeWhenTrue = undefined;
|
||||
return node;
|
||||
}
|
||||
|
||||
|
|
|
@ -2735,10 +2735,6 @@ export interface ConditionalExpression extends Expression {
|
|||
readonly whenTrue: Expression;
|
||||
readonly colonToken: ColonToken;
|
||||
readonly whenFalse: Expression;
|
||||
/** @internal*/
|
||||
flowNodeWhenTrue: FlowNode | undefined;
|
||||
/** @internal */
|
||||
flowNodeWhenFalse: FlowNode | undefined;
|
||||
}
|
||||
|
||||
export type FunctionBody = Block;
|
||||
|
|
|
@ -17,34 +17,42 @@ dependentReturnType1.ts(169,13): error TS2322: Type 'this' is not assignable to
|
|||
Type 'Unnamed' is not assignable to type 'string'.
|
||||
dependentReturnType1.ts(172,9): error TS2322: Type 'T & {}' is not assignable to type 'this'.
|
||||
'this' could be instantiated with an arbitrary type which could be unrelated to 'T & {}'.
|
||||
dependentReturnType1.ts(206,24): error TS2322: Type 'string' is not assignable to type 'number'.
|
||||
dependentReturnType1.ts(206,28): error TS2322: Type 'number' is not assignable to type 'string'.
|
||||
dependentReturnType1.ts(243,9): error TS2322: Type '""' is not assignable to type 'T extends 1 | 2 ? T extends 1 ? string : T extends 2 ? boolean : never : T extends 3 ? number : never'.
|
||||
dependentReturnType1.ts(245,9): error TS2322: Type 'true' is not assignable to type 'T extends 1 | 2 ? T extends 1 ? string : T extends 2 ? boolean : never : T extends 3 ? number : never'.
|
||||
dependentReturnType1.ts(247,5): error TS2322: Type '3' is not assignable to type 'T extends 1 | 2 ? T extends 1 ? string : T extends 2 ? boolean : never : T extends 3 ? number : never'.
|
||||
dependentReturnType1.ts(275,9): error TS2322: Type '1' is not assignable to type 'HelperCond<{ x: U; y: V; }, { x: string; y: true; }, 1, { x: number; y: false; }, 2>'.
|
||||
dependentReturnType1.ts(278,9): error TS2322: Type '2' is not assignable to type 'HelperCond<{ x: U; y: V; }, { x: string; y: true; }, 1, { x: number; y: false; }, 2>'.
|
||||
dependentReturnType1.ts(280,5): error TS2322: Type '0' is not assignable to type 'HelperCond<{ x: U; y: V; }, { x: string; y: true; }, 1, { x: number; y: false; }, 2>'.
|
||||
dependentReturnType1.ts(302,9): error TS2322: Type 'string' is not assignable to type 'string[]'.
|
||||
dependentReturnType1.ts(311,9): error TS2322: Type 'undefined' is not assignable to type 'T extends {} ? void : T extends undefined ? number : never'.
|
||||
dependentReturnType1.ts(313,5): error TS2322: Type 'number' is not assignable to type 'T extends {} ? void : T extends undefined ? number : never'.
|
||||
dependentReturnType1.ts(334,9): error TS2322: Type '1' is not assignable to type '4'.
|
||||
dependentReturnType1.ts(367,13): error TS2322: Type 'number' is not assignable to type 'T extends 1 ? number : T extends 2 ? string : never'.
|
||||
dependentReturnType1.ts(369,9): error TS2322: Type 'string' is not assignable to type 'T extends 1 ? number : T extends 2 ? string : never'.
|
||||
dependentReturnType1.ts(392,9): error TS2322: Type '2' is not assignable to type 'T extends true ? 1 : T extends false ? 2 : never'.
|
||||
dependentReturnType1.ts(402,13): error TS2322: Type 'number' is not assignable to type 'string'.
|
||||
dependentReturnType1.ts(412,9): error TS2322: Type 'true' is not assignable to type 'T extends [infer R] ? R : T extends number ? boolean : never'.
|
||||
dependentReturnType1.ts(414,5): error TS2322: Type '""' is not assignable to type 'T extends [infer R] ? R : T extends number ? boolean : never'.
|
||||
dependentReturnType1.ts(439,15): error TS2322: Type '1' is not assignable to type 'T extends true ? 1 : T extends false ? 2 : never'.
|
||||
dependentReturnType1.ts(441,11): error TS2322: Type '2' is not assignable to type 'T extends true ? 1 : T extends false ? 2 : never'.
|
||||
dependentReturnType1.ts(470,13): error TS2322: Type 'R' is not assignable to type 'ConditionalReturnType<T, R, EOp>'.
|
||||
dependentReturnType1.ts(472,13): error TS2322: Type 'R' is not assignable to type 'ConditionalReturnType<T, R, EOp>'.
|
||||
dependentReturnType1.ts(474,13): error TS2322: Type 'T' is not assignable to type 'ConditionalReturnType<T, R, EOp>'.
|
||||
dependentReturnType1.ts(488,9): error TS2322: Type 'R' is not assignable to type 'ConditionalReturnType<T, R, EOp>'.
|
||||
dependentReturnType1.ts(514,5): error TS2322: Type '1' is not assignable to type 'never'.
|
||||
dependentReturnType1.ts(195,12): error TS2322: Type '1 | 2' is not assignable to type 'T extends true ? 1 : T extends false ? 2 : never'.
|
||||
Type '1' is not assignable to type 'T extends true ? 1 : T extends false ? 2 : never'.
|
||||
dependentReturnType1.ts(201,12): error TS2322: Type 'number | T' is not assignable to type 'T extends "a" ? "a" : T extends "b" ? number : never'.
|
||||
Type 'number' is not assignable to type 'T extends "a" ? "a" : T extends "b" ? number : never'.
|
||||
dependentReturnType1.ts(207,12): error TS2322: Type 'number | T' is not assignable to type 'T extends "a" ? number : T extends "b" ? string : never'.
|
||||
Type 'number' is not assignable to type 'T extends "a" ? number : T extends "b" ? string : never'.
|
||||
dependentReturnType1.ts(244,9): error TS2322: Type '""' is not assignable to type 'T extends 1 | 2 ? T extends 1 ? string : T extends 2 ? boolean : never : T extends 3 ? number : never'.
|
||||
dependentReturnType1.ts(246,9): error TS2322: Type 'true' is not assignable to type 'T extends 1 | 2 ? T extends 1 ? string : T extends 2 ? boolean : never : T extends 3 ? number : never'.
|
||||
dependentReturnType1.ts(248,5): error TS2322: Type '3' is not assignable to type 'T extends 1 | 2 ? T extends 1 ? string : T extends 2 ? boolean : never : T extends 3 ? number : never'.
|
||||
dependentReturnType1.ts(276,9): error TS2322: Type '1' is not assignable to type 'HelperCond<{ x: U; y: V; }, { x: string; y: true; }, 1, { x: number; y: false; }, 2>'.
|
||||
dependentReturnType1.ts(279,9): error TS2322: Type '2' is not assignable to type 'HelperCond<{ x: U; y: V; }, { x: string; y: true; }, 1, { x: number; y: false; }, 2>'.
|
||||
dependentReturnType1.ts(281,5): error TS2322: Type '0' is not assignable to type 'HelperCond<{ x: U; y: V; }, { x: string; y: true; }, 1, { x: number; y: false; }, 2>'.
|
||||
dependentReturnType1.ts(303,9): error TS2322: Type 'string' is not assignable to type 'string[]'.
|
||||
dependentReturnType1.ts(312,9): error TS2322: Type 'undefined' is not assignable to type 'T extends {} ? void : T extends undefined ? number : never'.
|
||||
dependentReturnType1.ts(314,5): error TS2322: Type 'number' is not assignable to type 'T extends {} ? void : T extends undefined ? number : never'.
|
||||
dependentReturnType1.ts(335,9): error TS2322: Type '1' is not assignable to type '4'.
|
||||
dependentReturnType1.ts(368,13): error TS2322: Type 'number' is not assignable to type 'T extends 1 ? number : T extends 2 ? string : never'.
|
||||
dependentReturnType1.ts(370,9): error TS2322: Type 'string' is not assignable to type 'T extends 1 ? number : T extends 2 ? string : never'.
|
||||
dependentReturnType1.ts(393,9): error TS2322: Type '2' is not assignable to type 'T extends true ? 1 : T extends false ? 2 : never'.
|
||||
dependentReturnType1.ts(403,13): error TS2322: Type 'number' is not assignable to type 'string'.
|
||||
dependentReturnType1.ts(413,9): error TS2322: Type 'true' is not assignable to type 'T extends [infer R] ? R : T extends number ? boolean : never'.
|
||||
dependentReturnType1.ts(415,5): error TS2322: Type '""' is not assignable to type 'T extends [infer R] ? R : T extends number ? boolean : never'.
|
||||
dependentReturnType1.ts(440,15): error TS2322: Type '1' is not assignable to type 'T extends true ? 1 : T extends false ? 2 : never'.
|
||||
dependentReturnType1.ts(442,11): error TS2322: Type '2' is not assignable to type 'T extends true ? 1 : T extends false ? 2 : never'.
|
||||
dependentReturnType1.ts(471,13): error TS2322: Type 'R' is not assignable to type 'ConditionalReturnType<T, R, EOp>'.
|
||||
dependentReturnType1.ts(473,13): error TS2322: Type 'R' is not assignable to type 'ConditionalReturnType<T, R, EOp>'.
|
||||
dependentReturnType1.ts(475,13): error TS2322: Type 'T' is not assignable to type 'ConditionalReturnType<T, R, EOp>'.
|
||||
dependentReturnType1.ts(489,9): error TS2322: Type 'R' is not assignable to type 'ConditionalReturnType<T, R, EOp>'.
|
||||
dependentReturnType1.ts(499,12): error TS2322: Type '1 | 2' is not assignable to type 'T extends true ? 1 : T extends false ? 2 : never'.
|
||||
Type '1' is not assignable to type 'T extends true ? 1 : T extends false ? 2 : never'.
|
||||
dependentReturnType1.ts(504,12): error TS2322: Type '0 | "one" | "two"' is not assignable to type 'T extends 1 ? "one" : T extends 2 ? "two" : T extends "a" ? 0 : never'.
|
||||
Type '0' is not assignable to type 'T extends 1 ? "one" : T extends 2 ? "two" : T extends "a" ? 0 : never'.
|
||||
dependentReturnType1.ts(515,5): error TS2322: Type '1' is not assignable to type 'never'.
|
||||
|
||||
|
||||
==== dependentReturnType1.ts (39 errors) ====
|
||||
==== dependentReturnType1.ts (42 errors) ====
|
||||
interface A {
|
||||
1: number;
|
||||
2: string;
|
||||
|
@ -262,7 +270,8 @@ dependentReturnType1.ts(514,5): error TS2322: Type '1' is not assignable to type
|
|||
|
||||
function trivialConditional<T extends 1 | 2 | 3>(x: T): Aa[T] {
|
||||
if (x !== 1) {
|
||||
return x === 2 ? "" : true;
|
||||
if (x === 2) return "";
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
|
@ -271,23 +280,28 @@ dependentReturnType1.ts(514,5): error TS2322: Type '1' is not assignable to type
|
|||
|
||||
function conditional<T extends boolean>(x: T):
|
||||
T extends true ? 1 : T extends false ? 2 : never {
|
||||
return x ? 1 : 2; // Ok
|
||||
return x ? 1 : 2;
|
||||
~~~~~~~~~
|
||||
!!! error TS2322: Type '1 | 2' is not assignable to type 'T extends true ? 1 : T extends false ? 2 : never'.
|
||||
!!! error TS2322: Type '1' is not assignable to type 'T extends true ? 1 : T extends false ? 2 : never'.
|
||||
}
|
||||
|
||||
function contextualConditional<T extends "a" | "b">(
|
||||
x: T
|
||||
): T extends "a" ? "a" : T extends "b" ? number : never {
|
||||
return x === "a" ? x : parseInt(x); // Ok
|
||||
return x === "a" ? x : parseInt(x);
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2322: Type 'number | T' is not assignable to type 'T extends "a" ? "a" : T extends "b" ? number : never'.
|
||||
!!! error TS2322: Type 'number' is not assignable to type 'T extends "a" ? "a" : T extends "b" ? number : never'.
|
||||
}
|
||||
|
||||
function conditionalWithError<T extends "a" | "b">(
|
||||
x: T
|
||||
): T extends "a" ? number : T extends "b" ? string : never {
|
||||
return x === "a" ? x : parseInt(x); // Error
|
||||
~
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'number'.
|
||||
~~~~~~~~~~~
|
||||
!!! error TS2322: Type 'number' is not assignable to type 'string'.
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2322: Type 'number | T' is not assignable to type 'T extends "a" ? number : T extends "b" ? string : never'.
|
||||
!!! error TS2322: Type 'number' is not assignable to type 'T extends "a" ? number : T extends "b" ? string : never'.
|
||||
}
|
||||
|
||||
// Multiple indexed type reductions
|
||||
|
@ -624,11 +638,17 @@ dependentReturnType1.ts(514,5): error TS2322: Type '1' is not assignable to type
|
|||
// Return conditional expressions with parentheses
|
||||
function returnStuff1<T extends boolean>(x: T ): T extends true ? 1 : T extends false ? 2 : never {
|
||||
return (x ? (1) : 2);
|
||||
~~~~~~~~~~~~~
|
||||
!!! error TS2322: Type '1 | 2' is not assignable to type 'T extends true ? 1 : T extends false ? 2 : never'.
|
||||
!!! error TS2322: Type '1' is not assignable to type 'T extends true ? 1 : T extends false ? 2 : never'.
|
||||
}
|
||||
|
||||
function returnStuff2<T extends 1 | 2 | "a">(x: T ):
|
||||
T extends 1 ? "one" : T extends 2 ? "two" : T extends "a" ? 0 : never {
|
||||
return (typeof x === "string" ? 0 : (x === 1 ? ("one") : "two"));
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2322: Type '0 | "one" | "two"' is not assignable to type 'T extends 1 ? "one" : T extends 2 ? "two" : T extends "a" ? 0 : never'.
|
||||
!!! error TS2322: Type '0' is not assignable to type 'T extends 1 ? "one" : T extends 2 ? "two" : T extends "a" ? 0 : never'.
|
||||
}
|
||||
|
||||
// If the conditional type's input is `never`, then it resolves to `never`:
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -723,9 +723,7 @@ function trivialConditional<T extends 1 | 2 | 3>(x: T): Aa[T] {
|
|||
>1 : 1
|
||||
> : ^
|
||||
|
||||
return x === 2 ? "" : true;
|
||||
>x === 2 ? "" : true : true | ""
|
||||
> : ^^^^^^^^^
|
||||
if (x === 2) return "";
|
||||
>x === 2 : boolean
|
||||
> : ^^^^^^^
|
||||
>x : T
|
||||
|
@ -734,6 +732,8 @@ function trivialConditional<T extends 1 | 2 | 3>(x: T): Aa[T] {
|
|||
> : ^
|
||||
>"" : ""
|
||||
> : ^^
|
||||
|
||||
return true;
|
||||
>true : true
|
||||
> : ^^^^
|
||||
}
|
||||
|
@ -756,7 +756,7 @@ function conditional<T extends boolean>(x: T):
|
|||
>false : false
|
||||
> : ^^^^^
|
||||
|
||||
return x ? 1 : 2; // Ok
|
||||
return x ? 1 : 2;
|
||||
>x ? 1 : 2 : 1 | 2
|
||||
> : ^^^^^
|
||||
>x : T
|
||||
|
@ -776,17 +776,17 @@ function contextualConditional<T extends "a" | "b">(
|
|||
> : ^
|
||||
|
||||
): T extends "a" ? "a" : T extends "b" ? number : never {
|
||||
return x === "a" ? x : parseInt(x); // Ok
|
||||
>x === "a" ? x : parseInt(x) : number | "a"
|
||||
> : ^^^^^^^^^^^^
|
||||
return x === "a" ? x : parseInt(x);
|
||||
>x === "a" ? x : parseInt(x) : number | T
|
||||
> : ^^^^^^^^^^
|
||||
>x === "a" : boolean
|
||||
> : ^^^^^^^
|
||||
>x : T
|
||||
> : ^
|
||||
>"a" : "a"
|
||||
> : ^^^
|
||||
>x : "a"
|
||||
> : ^^^
|
||||
>x : T
|
||||
> : ^
|
||||
>parseInt(x) : number
|
||||
> : ^^^^^^
|
||||
>parseInt : (string: string, radix?: number) => number
|
||||
|
@ -805,16 +805,16 @@ function conditionalWithError<T extends "a" | "b">(
|
|||
|
||||
): T extends "a" ? number : T extends "b" ? string : never {
|
||||
return x === "a" ? x : parseInt(x); // Error
|
||||
>x === "a" ? x : parseInt(x) : number | "a"
|
||||
> : ^^^^^^^^^^^^
|
||||
>x === "a" ? x : parseInt(x) : number | T
|
||||
> : ^^^^^^^^^^
|
||||
>x === "a" : boolean
|
||||
> : ^^^^^^^
|
||||
>x : T
|
||||
> : ^
|
||||
>"a" : "a"
|
||||
> : ^^^
|
||||
>x : "a"
|
||||
> : ^^^
|
||||
>x : T
|
||||
> : ^
|
||||
>parseInt(x) : number
|
||||
> : ^^^^^^
|
||||
>parseInt : (string: string, radix?: number) => number
|
||||
|
|
|
@ -228,15 +228,16 @@ file.js(185,9): error TS2322: Type 'Record<string, MyObj[]>' is not assignable t
|
|||
* @returns {HelperCond<T, string, { start: Date, end: Date }, undefined, { start: Date, end: undefined }>}
|
||||
*/
|
||||
function transformDatesForAPI(start, end) {
|
||||
return end !== undefined ?
|
||||
{
|
||||
if (end !== undefined) {
|
||||
return {
|
||||
start: mapDateForAPI(start),
|
||||
end: mapDateForAPI(end),
|
||||
} :
|
||||
{
|
||||
start: mapDateForAPI(start),
|
||||
end: undefined
|
||||
};
|
||||
}
|
||||
return {
|
||||
start: mapDateForAPI(start),
|
||||
end: undefined
|
||||
};
|
||||
}
|
||||
|
||||
// File: Rocket.Chat/packages/agenda/src/Agenda.ts
|
||||
|
|
|
@ -436,12 +436,13 @@ function transformDatesForAPI(start, end) {
|
|||
>start : Symbol(start, Decl(file.js, 217, 30))
|
||||
>end : Symbol(end, Decl(file.js, 217, 36))
|
||||
|
||||
return end !== undefined ?
|
||||
if (end !== undefined) {
|
||||
>end : Symbol(end, Decl(file.js, 217, 36))
|
||||
>undefined : Symbol(undefined)
|
||||
{
|
||||
|
||||
return {
|
||||
start: mapDateForAPI(start),
|
||||
>start : Symbol(start, Decl(file.js, 219, 9))
|
||||
>start : Symbol(start, Decl(file.js, 219, 16))
|
||||
>mapDateForAPI : Symbol(mapDateForAPI, Decl(file.js, 199, 1))
|
||||
>start : Symbol(start, Decl(file.js, 217, 30))
|
||||
|
||||
|
@ -450,18 +451,19 @@ function transformDatesForAPI(start, end) {
|
|||
>mapDateForAPI : Symbol(mapDateForAPI, Decl(file.js, 199, 1))
|
||||
>end : Symbol(end, Decl(file.js, 217, 36))
|
||||
|
||||
} :
|
||||
{
|
||||
start: mapDateForAPI(start),
|
||||
>start : Symbol(start, Decl(file.js, 223, 9))
|
||||
};
|
||||
}
|
||||
return {
|
||||
start: mapDateForAPI(start),
|
||||
>start : Symbol(start, Decl(file.js, 224, 12))
|
||||
>mapDateForAPI : Symbol(mapDateForAPI, Decl(file.js, 199, 1))
|
||||
>start : Symbol(start, Decl(file.js, 217, 30))
|
||||
|
||||
end: undefined
|
||||
>end : Symbol(end, Decl(file.js, 224, 40))
|
||||
end: undefined
|
||||
>end : Symbol(end, Decl(file.js, 225, 36))
|
||||
>undefined : Symbol(undefined)
|
||||
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
// File: Rocket.Chat/packages/agenda/src/Agenda.ts
|
||||
|
@ -479,7 +481,7 @@ function transformDatesForAPI(start, end) {
|
|||
* @property {MyObj} data
|
||||
*/
|
||||
class NewAgenda {
|
||||
>NewAgenda : Symbol(NewAgenda, Decl(file.js, 227, 1))
|
||||
>NewAgenda : Symbol(NewAgenda, Decl(file.js, 228, 1))
|
||||
|
||||
/**
|
||||
* @param {string | number} interval
|
||||
|
@ -489,11 +491,11 @@ class NewAgenda {
|
|||
* @returns {Promise<Job>}
|
||||
*/
|
||||
async _createIntervalJob(interval, name, data, options) {
|
||||
>_createIntervalJob : Symbol(NewAgenda._createIntervalJob, Decl(file.js, 243, 17))
|
||||
>interval : Symbol(interval, Decl(file.js, 251, 29))
|
||||
>name : Symbol(name, Decl(file.js, 251, 38))
|
||||
>data : Symbol(data, Decl(file.js, 251, 44))
|
||||
>options : Symbol(options, Decl(file.js, 251, 50))
|
||||
>_createIntervalJob : Symbol(NewAgenda._createIntervalJob, Decl(file.js, 244, 17))
|
||||
>interval : Symbol(interval, Decl(file.js, 252, 29))
|
||||
>name : Symbol(name, Decl(file.js, 252, 38))
|
||||
>data : Symbol(data, Decl(file.js, 252, 44))
|
||||
>options : Symbol(options, Decl(file.js, 252, 50))
|
||||
|
||||
return /** @type {any} */ (undefined);
|
||||
>undefined : Symbol(undefined)
|
||||
|
@ -507,11 +509,11 @@ class NewAgenda {
|
|||
* @returns {Promise<Job[]> | undefined}
|
||||
*/
|
||||
_createIntervalJobs(interval, names, data, options) {
|
||||
>_createIntervalJobs : Symbol(NewAgenda._createIntervalJobs, Decl(file.js, 253, 5))
|
||||
>interval : Symbol(interval, Decl(file.js, 262, 24))
|
||||
>names : Symbol(names, Decl(file.js, 262, 33))
|
||||
>data : Symbol(data, Decl(file.js, 262, 40))
|
||||
>options : Symbol(options, Decl(file.js, 262, 46))
|
||||
>_createIntervalJobs : Symbol(NewAgenda._createIntervalJobs, Decl(file.js, 254, 5))
|
||||
>interval : Symbol(interval, Decl(file.js, 263, 24))
|
||||
>names : Symbol(names, Decl(file.js, 263, 33))
|
||||
>data : Symbol(data, Decl(file.js, 263, 40))
|
||||
>options : Symbol(options, Decl(file.js, 263, 46))
|
||||
|
||||
return undefined;
|
||||
>undefined : Symbol(undefined)
|
||||
|
@ -526,39 +528,39 @@ class NewAgenda {
|
|||
* @returns {Promise<HelperCond<T, string, Job, string[], Job[] | undefined>>}
|
||||
*/
|
||||
async newEvery(interval, name, data, options) {
|
||||
>newEvery : Symbol(NewAgenda.newEvery, Decl(file.js, 264, 5))
|
||||
>interval : Symbol(interval, Decl(file.js, 274, 19))
|
||||
>name : Symbol(name, Decl(file.js, 274, 28))
|
||||
>data : Symbol(data, Decl(file.js, 274, 34))
|
||||
>options : Symbol(options, Decl(file.js, 274, 40))
|
||||
>newEvery : Symbol(NewAgenda.newEvery, Decl(file.js, 265, 5))
|
||||
>interval : Symbol(interval, Decl(file.js, 275, 19))
|
||||
>name : Symbol(name, Decl(file.js, 275, 28))
|
||||
>data : Symbol(data, Decl(file.js, 275, 34))
|
||||
>options : Symbol(options, Decl(file.js, 275, 40))
|
||||
|
||||
if (typeof name === 'string') {
|
||||
>name : Symbol(name, Decl(file.js, 274, 28))
|
||||
>name : Symbol(name, Decl(file.js, 275, 28))
|
||||
|
||||
return this._createIntervalJob(interval, name, data, options); // Ok
|
||||
>this._createIntervalJob : Symbol(NewAgenda._createIntervalJob, Decl(file.js, 243, 17))
|
||||
>this : Symbol(NewAgenda, Decl(file.js, 227, 1))
|
||||
>_createIntervalJob : Symbol(NewAgenda._createIntervalJob, Decl(file.js, 243, 17))
|
||||
>interval : Symbol(interval, Decl(file.js, 274, 19))
|
||||
>name : Symbol(name, Decl(file.js, 274, 28))
|
||||
>data : Symbol(data, Decl(file.js, 274, 34))
|
||||
>options : Symbol(options, Decl(file.js, 274, 40))
|
||||
>this._createIntervalJob : Symbol(NewAgenda._createIntervalJob, Decl(file.js, 244, 17))
|
||||
>this : Symbol(NewAgenda, Decl(file.js, 228, 1))
|
||||
>_createIntervalJob : Symbol(NewAgenda._createIntervalJob, Decl(file.js, 244, 17))
|
||||
>interval : Symbol(interval, Decl(file.js, 275, 19))
|
||||
>name : Symbol(name, Decl(file.js, 275, 28))
|
||||
>data : Symbol(data, Decl(file.js, 275, 34))
|
||||
>options : Symbol(options, Decl(file.js, 275, 40))
|
||||
}
|
||||
|
||||
if (Array.isArray(name)) {
|
||||
>Array.isArray : Symbol(ArrayConstructor.isArray, Decl(lib.es5.d.ts, --, --))
|
||||
>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 4 more)
|
||||
>isArray : Symbol(ArrayConstructor.isArray, Decl(lib.es5.d.ts, --, --))
|
||||
>name : Symbol(name, Decl(file.js, 274, 28))
|
||||
>name : Symbol(name, Decl(file.js, 275, 28))
|
||||
|
||||
return this._createIntervalJobs(interval, name, data, options); // Ok
|
||||
>this._createIntervalJobs : Symbol(NewAgenda._createIntervalJobs, Decl(file.js, 253, 5))
|
||||
>this : Symbol(NewAgenda, Decl(file.js, 227, 1))
|
||||
>_createIntervalJobs : Symbol(NewAgenda._createIntervalJobs, Decl(file.js, 253, 5))
|
||||
>interval : Symbol(interval, Decl(file.js, 274, 19))
|
||||
>name : Symbol(name, Decl(file.js, 274, 28))
|
||||
>data : Symbol(data, Decl(file.js, 274, 34))
|
||||
>options : Symbol(options, Decl(file.js, 274, 40))
|
||||
>this._createIntervalJobs : Symbol(NewAgenda._createIntervalJobs, Decl(file.js, 254, 5))
|
||||
>this : Symbol(NewAgenda, Decl(file.js, 228, 1))
|
||||
>_createIntervalJobs : Symbol(NewAgenda._createIntervalJobs, Decl(file.js, 254, 5))
|
||||
>interval : Symbol(interval, Decl(file.js, 275, 19))
|
||||
>name : Symbol(name, Decl(file.js, 275, 28))
|
||||
>data : Symbol(data, Decl(file.js, 275, 34))
|
||||
>options : Symbol(options, Decl(file.js, 275, 40))
|
||||
}
|
||||
|
||||
throw new Error('Unexpected error: Invalid job name(s)');
|
||||
|
@ -574,21 +576,21 @@ class NewAgenda {
|
|||
* @returns {HelperCond<T, string, string, null | undefined, null>}
|
||||
*/
|
||||
function transform1(value) {
|
||||
>transform1 : Symbol(transform1, Decl(file.js, 285, 1))
|
||||
>value : Symbol(value, Decl(file.js, 294, 20))
|
||||
>transform1 : Symbol(transform1, Decl(file.js, 286, 1))
|
||||
>value : Symbol(value, Decl(file.js, 295, 20))
|
||||
|
||||
if (value == null) return null; // Ok
|
||||
>value : Symbol(value, Decl(file.js, 294, 20))
|
||||
>value : Symbol(value, Decl(file.js, 295, 20))
|
||||
|
||||
if (typeof value !== 'string') {
|
||||
>value : Symbol(value, Decl(file.js, 294, 20))
|
||||
>value : Symbol(value, Decl(file.js, 295, 20))
|
||||
|
||||
throw new Error();
|
||||
>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2022.error.d.ts, --, --))
|
||||
}
|
||||
return value.toLowerCase(); // Ok
|
||||
>value.toLowerCase : Symbol(String.toLowerCase, Decl(lib.es5.d.ts, --, --))
|
||||
>value : Symbol(value, Decl(file.js, 294, 20))
|
||||
>value : Symbol(value, Decl(file.js, 295, 20))
|
||||
>toLowerCase : Symbol(String.toLowerCase, Decl(lib.es5.d.ts, --, --))
|
||||
}
|
||||
|
||||
|
|
|
@ -744,16 +744,15 @@ function transformDatesForAPI(start, end) {
|
|||
>end : T | undefined
|
||||
> : ^^^^^^^^^^^^^
|
||||
|
||||
return end !== undefined ?
|
||||
>end !== undefined ? { start: mapDateForAPI(start), end: mapDateForAPI(end), } : { start: mapDateForAPI(start), end: undefined } : { start: Date; end: Date; } | { start: Date; end: undefined; }
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
if (end !== undefined) {
|
||||
>end !== undefined : boolean
|
||||
> : ^^^^^^^
|
||||
>end : T | undefined
|
||||
> : ^^^^^^^^^^^^^
|
||||
>undefined : undefined
|
||||
> : ^^^^^^^^^
|
||||
{
|
||||
|
||||
return {
|
||||
>{ start: mapDateForAPI(start), end: mapDateForAPI(end), } : { start: Date; end: Date; }
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
|
@ -777,12 +776,13 @@ function transformDatesForAPI(start, end) {
|
|||
>end : string
|
||||
> : ^^^^^^
|
||||
|
||||
} :
|
||||
{
|
||||
>{ start: mapDateForAPI(start), end: undefined } : { start: Date; end: undefined; }
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
};
|
||||
}
|
||||
return {
|
||||
>{ start: mapDateForAPI(start), end: undefined } : { start: Date; end: undefined; }
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
start: mapDateForAPI(start),
|
||||
start: mapDateForAPI(start),
|
||||
>start : Date
|
||||
> : ^^^^
|
||||
>mapDateForAPI(start) : Date
|
||||
|
@ -792,13 +792,13 @@ function transformDatesForAPI(start, end) {
|
|||
>start : string
|
||||
> : ^^^^^^
|
||||
|
||||
end: undefined
|
||||
end: undefined
|
||||
>end : undefined
|
||||
> : ^^^^^^^^^
|
||||
>undefined : undefined
|
||||
> : ^^^^^^^^^
|
||||
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
// File: Rocket.Chat/packages/agenda/src/Agenda.ts
|
||||
|
|
|
@ -171,15 +171,16 @@ dependentReturnType3.ts(141,9): error TS2322: Type 'Record<string, object[]>' is
|
|||
start: string,
|
||||
end?: T
|
||||
): HelperCond<T, string, { start: Date, end: Date }, undefined, { start: Date, end: undefined }> {
|
||||
return end !== undefined ? // Ok
|
||||
{
|
||||
if (end !== undefined) {
|
||||
return {
|
||||
start: mapDateForAPI(start),
|
||||
end: mapDateForAPI(end),
|
||||
} :
|
||||
{
|
||||
start: mapDateForAPI(start),
|
||||
end: undefined
|
||||
};
|
||||
}
|
||||
return {
|
||||
start: mapDateForAPI(start),
|
||||
end: undefined
|
||||
};
|
||||
}
|
||||
|
||||
// File: Rocket.Chat/packages/agenda/src/Agenda.ts
|
||||
|
|
|
@ -517,12 +517,13 @@ export function transformDatesForAPI<T extends string | undefined>(
|
|||
>Date : Symbol(Date, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.scripthost.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --))
|
||||
>end : Symbol(end, Decl(dependentReturnType3.ts, 160, 78))
|
||||
|
||||
return end !== undefined ? // Ok
|
||||
if (end !== undefined) {
|
||||
>end : Symbol(end, Decl(dependentReturnType3.ts, 158, 18))
|
||||
>undefined : Symbol(undefined)
|
||||
{
|
||||
|
||||
return {
|
||||
start: mapDateForAPI(start),
|
||||
>start : Symbol(start, Decl(dependentReturnType3.ts, 162, 9))
|
||||
>start : Symbol(start, Decl(dependentReturnType3.ts, 162, 16))
|
||||
>mapDateForAPI : Symbol(mapDateForAPI, Decl(dependentReturnType3.ts, 153, 1))
|
||||
>start : Symbol(start, Decl(dependentReturnType3.ts, 157, 67))
|
||||
|
||||
|
@ -531,119 +532,120 @@ export function transformDatesForAPI<T extends string | undefined>(
|
|||
>mapDateForAPI : Symbol(mapDateForAPI, Decl(dependentReturnType3.ts, 153, 1))
|
||||
>end : Symbol(end, Decl(dependentReturnType3.ts, 158, 18))
|
||||
|
||||
} :
|
||||
{
|
||||
start: mapDateForAPI(start),
|
||||
>start : Symbol(start, Decl(dependentReturnType3.ts, 166, 9))
|
||||
};
|
||||
}
|
||||
return {
|
||||
start: mapDateForAPI(start),
|
||||
>start : Symbol(start, Decl(dependentReturnType3.ts, 167, 12))
|
||||
>mapDateForAPI : Symbol(mapDateForAPI, Decl(dependentReturnType3.ts, 153, 1))
|
||||
>start : Symbol(start, Decl(dependentReturnType3.ts, 157, 67))
|
||||
|
||||
end: undefined
|
||||
>end : Symbol(end, Decl(dependentReturnType3.ts, 167, 40))
|
||||
end: undefined
|
||||
>end : Symbol(end, Decl(dependentReturnType3.ts, 168, 36))
|
||||
>undefined : Symbol(undefined)
|
||||
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
// File: Rocket.Chat/packages/agenda/src/Agenda.ts
|
||||
type RepeatOptions = object;
|
||||
>RepeatOptions : Symbol(RepeatOptions, Decl(dependentReturnType3.ts, 170, 1))
|
||||
>RepeatOptions : Symbol(RepeatOptions, Decl(dependentReturnType3.ts, 171, 1))
|
||||
|
||||
type Job = object;
|
||||
>Job : Symbol(Job, Decl(dependentReturnType3.ts, 173, 28))
|
||||
>Job : Symbol(Job, Decl(dependentReturnType3.ts, 174, 28))
|
||||
|
||||
type IJob = { data: object };
|
||||
>IJob : Symbol(IJob, Decl(dependentReturnType3.ts, 174, 18))
|
||||
>data : Symbol(data, Decl(dependentReturnType3.ts, 175, 13))
|
||||
>IJob : Symbol(IJob, Decl(dependentReturnType3.ts, 175, 18))
|
||||
>data : Symbol(data, Decl(dependentReturnType3.ts, 176, 13))
|
||||
|
||||
class NewAgenda {
|
||||
>NewAgenda : Symbol(NewAgenda, Decl(dependentReturnType3.ts, 175, 29))
|
||||
>NewAgenda : Symbol(NewAgenda, Decl(dependentReturnType3.ts, 176, 29))
|
||||
|
||||
public async _createIntervalJob(interval: string | number, name: string, data: IJob['data'], options: RepeatOptions): Promise<Job> { return undefined as any; }
|
||||
>_createIntervalJob : Symbol(NewAgenda._createIntervalJob, Decl(dependentReturnType3.ts, 176, 17))
|
||||
>interval : Symbol(interval, Decl(dependentReturnType3.ts, 177, 36))
|
||||
>name : Symbol(name, Decl(dependentReturnType3.ts, 177, 62))
|
||||
>data : Symbol(data, Decl(dependentReturnType3.ts, 177, 76))
|
||||
>IJob : Symbol(IJob, Decl(dependentReturnType3.ts, 174, 18))
|
||||
>options : Symbol(options, Decl(dependentReturnType3.ts, 177, 96))
|
||||
>RepeatOptions : Symbol(RepeatOptions, Decl(dependentReturnType3.ts, 170, 1))
|
||||
>_createIntervalJob : Symbol(NewAgenda._createIntervalJob, Decl(dependentReturnType3.ts, 177, 17))
|
||||
>interval : Symbol(interval, Decl(dependentReturnType3.ts, 178, 36))
|
||||
>name : Symbol(name, Decl(dependentReturnType3.ts, 178, 62))
|
||||
>data : Symbol(data, Decl(dependentReturnType3.ts, 178, 76))
|
||||
>IJob : Symbol(IJob, Decl(dependentReturnType3.ts, 175, 18))
|
||||
>options : Symbol(options, Decl(dependentReturnType3.ts, 178, 96))
|
||||
>RepeatOptions : Symbol(RepeatOptions, Decl(dependentReturnType3.ts, 171, 1))
|
||||
>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --))
|
||||
>Job : Symbol(Job, Decl(dependentReturnType3.ts, 173, 28))
|
||||
>Job : Symbol(Job, Decl(dependentReturnType3.ts, 174, 28))
|
||||
>undefined : Symbol(undefined)
|
||||
|
||||
private _createIntervalJobs(
|
||||
>_createIntervalJobs : Symbol(NewAgenda._createIntervalJobs, Decl(dependentReturnType3.ts, 177, 163))
|
||||
>_createIntervalJobs : Symbol(NewAgenda._createIntervalJobs, Decl(dependentReturnType3.ts, 178, 163))
|
||||
|
||||
interval: string | number,
|
||||
>interval : Symbol(interval, Decl(dependentReturnType3.ts, 178, 32))
|
||||
>interval : Symbol(interval, Decl(dependentReturnType3.ts, 179, 32))
|
||||
|
||||
names: string[],
|
||||
>names : Symbol(names, Decl(dependentReturnType3.ts, 179, 34))
|
||||
>names : Symbol(names, Decl(dependentReturnType3.ts, 180, 34))
|
||||
|
||||
data: IJob['data'],
|
||||
>data : Symbol(data, Decl(dependentReturnType3.ts, 180, 24))
|
||||
>IJob : Symbol(IJob, Decl(dependentReturnType3.ts, 174, 18))
|
||||
>data : Symbol(data, Decl(dependentReturnType3.ts, 181, 24))
|
||||
>IJob : Symbol(IJob, Decl(dependentReturnType3.ts, 175, 18))
|
||||
|
||||
options: RepeatOptions,
|
||||
>options : Symbol(options, Decl(dependentReturnType3.ts, 181, 27))
|
||||
>RepeatOptions : Symbol(RepeatOptions, Decl(dependentReturnType3.ts, 170, 1))
|
||||
>options : Symbol(options, Decl(dependentReturnType3.ts, 182, 27))
|
||||
>RepeatOptions : Symbol(RepeatOptions, Decl(dependentReturnType3.ts, 171, 1))
|
||||
|
||||
): Promise<Job[]> | undefined { return undefined as any; }
|
||||
>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --))
|
||||
>Job : Symbol(Job, Decl(dependentReturnType3.ts, 173, 28))
|
||||
>Job : Symbol(Job, Decl(dependentReturnType3.ts, 174, 28))
|
||||
>undefined : Symbol(undefined)
|
||||
|
||||
public async newEvery<T extends string | string[]>(
|
||||
>newEvery : Symbol(NewAgenda.newEvery, Decl(dependentReturnType3.ts, 183, 62))
|
||||
>T : Symbol(T, Decl(dependentReturnType3.ts, 185, 26))
|
||||
>newEvery : Symbol(NewAgenda.newEvery, Decl(dependentReturnType3.ts, 184, 62))
|
||||
>T : Symbol(T, Decl(dependentReturnType3.ts, 186, 26))
|
||||
|
||||
interval: string | number,
|
||||
>interval : Symbol(interval, Decl(dependentReturnType3.ts, 185, 55))
|
||||
>interval : Symbol(interval, Decl(dependentReturnType3.ts, 186, 55))
|
||||
|
||||
name: T,
|
||||
>name : Symbol(name, Decl(dependentReturnType3.ts, 186, 34))
|
||||
>T : Symbol(T, Decl(dependentReturnType3.ts, 185, 26))
|
||||
>name : Symbol(name, Decl(dependentReturnType3.ts, 187, 34))
|
||||
>T : Symbol(T, Decl(dependentReturnType3.ts, 186, 26))
|
||||
|
||||
data: IJob['data'],
|
||||
>data : Symbol(data, Decl(dependentReturnType3.ts, 187, 16))
|
||||
>IJob : Symbol(IJob, Decl(dependentReturnType3.ts, 174, 18))
|
||||
>data : Symbol(data, Decl(dependentReturnType3.ts, 188, 16))
|
||||
>IJob : Symbol(IJob, Decl(dependentReturnType3.ts, 175, 18))
|
||||
|
||||
options: RepeatOptions): Promise<HelperCond<T, string, Job, string[], Job[] | undefined>> {
|
||||
>options : Symbol(options, Decl(dependentReturnType3.ts, 188, 27))
|
||||
>RepeatOptions : Symbol(RepeatOptions, Decl(dependentReturnType3.ts, 170, 1))
|
||||
>options : Symbol(options, Decl(dependentReturnType3.ts, 189, 27))
|
||||
>RepeatOptions : Symbol(RepeatOptions, Decl(dependentReturnType3.ts, 171, 1))
|
||||
>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --))
|
||||
>HelperCond : Symbol(HelperCond, Decl(dependentReturnType3.ts, 0, 0))
|
||||
>T : Symbol(T, Decl(dependentReturnType3.ts, 185, 26))
|
||||
>Job : Symbol(Job, Decl(dependentReturnType3.ts, 173, 28))
|
||||
>Job : Symbol(Job, Decl(dependentReturnType3.ts, 173, 28))
|
||||
>T : Symbol(T, Decl(dependentReturnType3.ts, 186, 26))
|
||||
>Job : Symbol(Job, Decl(dependentReturnType3.ts, 174, 28))
|
||||
>Job : Symbol(Job, Decl(dependentReturnType3.ts, 174, 28))
|
||||
|
||||
if (typeof name === 'string') {
|
||||
>name : Symbol(name, Decl(dependentReturnType3.ts, 186, 34))
|
||||
>name : Symbol(name, Decl(dependentReturnType3.ts, 187, 34))
|
||||
|
||||
return this._createIntervalJob(interval, name, data, options); // Ok
|
||||
>this._createIntervalJob : Symbol(NewAgenda._createIntervalJob, Decl(dependentReturnType3.ts, 176, 17))
|
||||
>this : Symbol(NewAgenda, Decl(dependentReturnType3.ts, 175, 29))
|
||||
>_createIntervalJob : Symbol(NewAgenda._createIntervalJob, Decl(dependentReturnType3.ts, 176, 17))
|
||||
>interval : Symbol(interval, Decl(dependentReturnType3.ts, 185, 55))
|
||||
>name : Symbol(name, Decl(dependentReturnType3.ts, 186, 34))
|
||||
>data : Symbol(data, Decl(dependentReturnType3.ts, 187, 16))
|
||||
>options : Symbol(options, Decl(dependentReturnType3.ts, 188, 27))
|
||||
>this._createIntervalJob : Symbol(NewAgenda._createIntervalJob, Decl(dependentReturnType3.ts, 177, 17))
|
||||
>this : Symbol(NewAgenda, Decl(dependentReturnType3.ts, 176, 29))
|
||||
>_createIntervalJob : Symbol(NewAgenda._createIntervalJob, Decl(dependentReturnType3.ts, 177, 17))
|
||||
>interval : Symbol(interval, Decl(dependentReturnType3.ts, 186, 55))
|
||||
>name : Symbol(name, Decl(dependentReturnType3.ts, 187, 34))
|
||||
>data : Symbol(data, Decl(dependentReturnType3.ts, 188, 16))
|
||||
>options : Symbol(options, Decl(dependentReturnType3.ts, 189, 27))
|
||||
}
|
||||
|
||||
if (Array.isArray(name)) {
|
||||
>Array.isArray : Symbol(ArrayConstructor.isArray, Decl(lib.es5.d.ts, --, --))
|
||||
>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --))
|
||||
>isArray : Symbol(ArrayConstructor.isArray, Decl(lib.es5.d.ts, --, --))
|
||||
>name : Symbol(name, Decl(dependentReturnType3.ts, 186, 34))
|
||||
>name : Symbol(name, Decl(dependentReturnType3.ts, 187, 34))
|
||||
|
||||
return this._createIntervalJobs(interval, name, data, options); // Ok
|
||||
>this._createIntervalJobs : Symbol(NewAgenda._createIntervalJobs, Decl(dependentReturnType3.ts, 177, 163))
|
||||
>this : Symbol(NewAgenda, Decl(dependentReturnType3.ts, 175, 29))
|
||||
>_createIntervalJobs : Symbol(NewAgenda._createIntervalJobs, Decl(dependentReturnType3.ts, 177, 163))
|
||||
>interval : Symbol(interval, Decl(dependentReturnType3.ts, 185, 55))
|
||||
>name : Symbol(name, Decl(dependentReturnType3.ts, 186, 34))
|
||||
>data : Symbol(data, Decl(dependentReturnType3.ts, 187, 16))
|
||||
>options : Symbol(options, Decl(dependentReturnType3.ts, 188, 27))
|
||||
>this._createIntervalJobs : Symbol(NewAgenda._createIntervalJobs, Decl(dependentReturnType3.ts, 178, 163))
|
||||
>this : Symbol(NewAgenda, Decl(dependentReturnType3.ts, 176, 29))
|
||||
>_createIntervalJobs : Symbol(NewAgenda._createIntervalJobs, Decl(dependentReturnType3.ts, 178, 163))
|
||||
>interval : Symbol(interval, Decl(dependentReturnType3.ts, 186, 55))
|
||||
>name : Symbol(name, Decl(dependentReturnType3.ts, 187, 34))
|
||||
>data : Symbol(data, Decl(dependentReturnType3.ts, 188, 16))
|
||||
>options : Symbol(options, Decl(dependentReturnType3.ts, 189, 27))
|
||||
|
||||
// Possible bug in original: createIntervalJobs can return undefined, but the original overload did not acount for that.
|
||||
}
|
||||
|
@ -656,24 +658,24 @@ class NewAgenda {
|
|||
// File: angular/packages/common/src/pipes/case_conversion_pipes.ts
|
||||
|
||||
function transform1<T extends string | null | undefined>(value: T): HelperCond<T, string, string, null | undefined, null> {
|
||||
>transform1 : Symbol(transform1, Decl(dependentReturnType3.ts, 201, 1))
|
||||
>T : Symbol(T, Decl(dependentReturnType3.ts, 205, 20))
|
||||
>value : Symbol(value, Decl(dependentReturnType3.ts, 205, 57))
|
||||
>T : Symbol(T, Decl(dependentReturnType3.ts, 205, 20))
|
||||
>transform1 : Symbol(transform1, Decl(dependentReturnType3.ts, 202, 1))
|
||||
>T : Symbol(T, Decl(dependentReturnType3.ts, 206, 20))
|
||||
>value : Symbol(value, Decl(dependentReturnType3.ts, 206, 57))
|
||||
>T : Symbol(T, Decl(dependentReturnType3.ts, 206, 20))
|
||||
>HelperCond : Symbol(HelperCond, Decl(dependentReturnType3.ts, 0, 0))
|
||||
>T : Symbol(T, Decl(dependentReturnType3.ts, 205, 20))
|
||||
>T : Symbol(T, Decl(dependentReturnType3.ts, 206, 20))
|
||||
|
||||
if (value == null) return null; // Ok
|
||||
>value : Symbol(value, Decl(dependentReturnType3.ts, 205, 57))
|
||||
>value : Symbol(value, Decl(dependentReturnType3.ts, 206, 57))
|
||||
|
||||
if (typeof value !== 'string') {
|
||||
>value : Symbol(value, Decl(dependentReturnType3.ts, 205, 57))
|
||||
>value : Symbol(value, Decl(dependentReturnType3.ts, 206, 57))
|
||||
|
||||
throw new Error();
|
||||
>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
||||
}
|
||||
return value.toLowerCase(); // Ok
|
||||
>value.toLowerCase : Symbol(String.toLowerCase, Decl(lib.es5.d.ts, --, --))
|
||||
>value : Symbol(value, Decl(dependentReturnType3.ts, 205, 57))
|
||||
>value : Symbol(value, Decl(dependentReturnType3.ts, 206, 57))
|
||||
>toLowerCase : Symbol(String.toLowerCase, Decl(lib.es5.d.ts, --, --))
|
||||
}
|
||||
|
|
|
@ -748,16 +748,15 @@ export function transformDatesForAPI<T extends string | undefined>(
|
|||
>end : undefined
|
||||
> : ^^^^^^^^^
|
||||
|
||||
return end !== undefined ? // Ok
|
||||
>end !== undefined ? // Ok { start: mapDateForAPI(start), end: mapDateForAPI(end), } : { start: mapDateForAPI(start), end: undefined } : { start: Date; end: Date; } | { start: Date; end: undefined; }
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
if (end !== undefined) {
|
||||
>end !== undefined : boolean
|
||||
> : ^^^^^^^
|
||||
>end : T | undefined
|
||||
> : ^^^^^^^^^^^^^
|
||||
>undefined : undefined
|
||||
> : ^^^^^^^^^
|
||||
{
|
||||
|
||||
return {
|
||||
>{ start: mapDateForAPI(start), end: mapDateForAPI(end), } : { start: Date; end: Date; }
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
|
@ -781,12 +780,13 @@ export function transformDatesForAPI<T extends string | undefined>(
|
|||
>end : string
|
||||
> : ^^^^^^
|
||||
|
||||
} :
|
||||
{
|
||||
>{ start: mapDateForAPI(start), end: undefined } : { start: Date; end: undefined; }
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
};
|
||||
}
|
||||
return {
|
||||
>{ start: mapDateForAPI(start), end: undefined } : { start: Date; end: undefined; }
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
start: mapDateForAPI(start),
|
||||
start: mapDateForAPI(start),
|
||||
>start : Date
|
||||
> : ^^^^
|
||||
>mapDateForAPI(start) : Date
|
||||
|
@ -796,13 +796,13 @@ export function transformDatesForAPI<T extends string | undefined>(
|
|||
>start : string
|
||||
> : ^^^^^^
|
||||
|
||||
end: undefined
|
||||
end: undefined
|
||||
>end : undefined
|
||||
> : ^^^^^^^^^
|
||||
>undefined : undefined
|
||||
> : ^^^^^^^^^
|
||||
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
// File: Rocket.Chat/packages/agenda/src/Agenda.ts
|
||||
|
|
|
@ -1,24 +1,24 @@
|
|||
file.ts(28,26): error TS2322: Type 'true' is not assignable to type 'SomeInterfaceBad<T>[U]'.
|
||||
file.ts(33,22): error TS2322: Type 'true' is not assignable to type 'SomeInterfaceBad<T>[U]'.
|
||||
Type 'true' is not assignable to type 'T extends 1 ? true : T extends 2 ? false : never'.
|
||||
file.ts(28,33): error TS2322: Type 'false' is not assignable to type 'SomeInterfaceBad<T>[U]'.
|
||||
file.ts(34,9): error TS2322: Type 'false' is not assignable to type 'SomeInterfaceBad<T>[U]'.
|
||||
Type 'false' is not assignable to type 'T extends 1 ? true : T extends 2 ? false : never'.
|
||||
file.ts(30,16): error TS2322: Type '1' is not assignable to type 'SomeInterfaceBad<T>[U]'.
|
||||
file.ts(36,12): error TS2322: Type '1' is not assignable to type 'SomeInterfaceBad<T>[U]'.
|
||||
Type '1' is not assignable to type 'T extends true ? 1 : T extends false ? 2 : never'.
|
||||
file.ts(30,20): error TS2322: Type '2' is not assignable to type 'SomeInterfaceBad<T>[U]'.
|
||||
file.ts(37,5): error TS2322: Type '2' is not assignable to type 'SomeInterfaceBad<T>[U]'.
|
||||
Type '2' is not assignable to type 'T extends true ? 1 : T extends false ? 2 : never'.
|
||||
file.ts(80,13): error TS2322: Type '1' is not assignable to type 'this extends Sub1 ? 1 : this extends Sub2 ? 2 : never'.
|
||||
file.ts(82,9): error TS2322: Type '2' is not assignable to type 'this extends Sub1 ? 1 : this extends Sub2 ? 2 : never'.
|
||||
file.ts(94,16): error TS2322: Type '1' is not assignable to type 'T extends true ? 1 : T extends false ? 2 : never'.
|
||||
file.ts(94,20): error TS2322: Type '2' is not assignable to type 'T extends true ? 1 : T extends false ? 2 : never'.
|
||||
file.ts(98,100): error TS2322: Type '1 | 2' is not assignable to type 'T extends true ? 1 : T extends false ? 2 : never'.
|
||||
file.ts(89,13): error TS2322: Type '1' is not assignable to type 'this extends Sub1 ? 1 : this extends Sub2 ? 2 : never'.
|
||||
file.ts(91,9): error TS2322: Type '2' is not assignable to type 'this extends Sub1 ? 1 : this extends Sub2 ? 2 : never'.
|
||||
file.ts(103,12): error TS2322: Type '1' is not assignable to type 'T extends true ? 1 : T extends false ? 2 : never'.
|
||||
file.ts(104,5): error TS2322: Type '2' is not assignable to type 'T extends true ? 1 : T extends false ? 2 : never'.
|
||||
file.ts(108,100): error TS2322: Type '1 | 2' is not assignable to type 'T extends true ? 1 : T extends false ? 2 : never'.
|
||||
Type '1' is not assignable to type 'T extends true ? 1 : T extends false ? 2 : never'.
|
||||
file.ts(106,9): error TS2322: Type 'number' is not assignable to type 'SomeCond<T>'.
|
||||
file.ts(106,9): error TS2589: Type instantiation is excessively deep and possibly infinite.
|
||||
file.ts(108,5): error TS2322: Type 'number' is not assignable to type 'SomeCond<T>'.
|
||||
file.ts(114,60): error TS2366: Function lacks ending return statement and return type does not include 'undefined'.
|
||||
file.ts(116,9): error TS2322: Type '"one"' is not assignable to type 'OtherCond<U> | OtherCond<V>'.
|
||||
file.ts(126,9): error TS2322: Type '"a"' is not assignable to type 'T extends (infer P)[] ? P : T extends number ? undefined : never'.
|
||||
file.ts(128,5): error TS2322: Type 'undefined' is not assignable to type 'T extends (infer P)[] ? P : T extends number ? undefined : never'.
|
||||
file.ts(116,9): error TS2322: Type 'number' is not assignable to type 'SomeCond<T>'.
|
||||
file.ts(116,9): error TS2589: Type instantiation is excessively deep and possibly infinite.
|
||||
file.ts(118,5): error TS2322: Type 'number' is not assignable to type 'SomeCond<T>'.
|
||||
file.ts(124,60): error TS2366: Function lacks ending return statement and return type does not include 'undefined'.
|
||||
file.ts(126,9): error TS2322: Type '"one"' is not assignable to type 'OtherCond<U> | OtherCond<V>'.
|
||||
file.ts(136,9): error TS2322: Type '"a"' is not assignable to type 'T extends (infer P)[] ? P : T extends number ? undefined : never'.
|
||||
file.ts(138,5): error TS2322: Type 'undefined' is not assignable to type 'T extends (infer P)[] ? P : T extends number ? undefined : never'.
|
||||
|
||||
|
||||
==== file.ts (16 errors) ====
|
||||
|
@ -27,7 +27,8 @@ file.ts(128,5): error TS2322: Type 'undefined' is not assignable to type 'T exte
|
|||
return inner();
|
||||
|
||||
function inner(): T extends true ? 1 : T extends false ? 2 : never {
|
||||
return x ? 1 : 2;
|
||||
if (x) return 1;
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -36,7 +37,11 @@ file.ts(128,5): error TS2322: Type 'undefined' is not assignable to type 'T exte
|
|||
function fun6<T extends boolean>(x: T, y: undefined): T extends true ? 1 : T extends false ? 2 : never;
|
||||
function fun6(x: boolean): 1 | 2 | string;
|
||||
function fun6<T extends boolean>(x: T, y?: string): T extends true ? 1 | string : T extends false ? 2 : never {
|
||||
return x ? y !== undefined ? y : 1 : 2;
|
||||
if (x) {
|
||||
if (y !== undefined) return y;
|
||||
return 1;
|
||||
}
|
||||
return 2;
|
||||
}
|
||||
|
||||
// Indexed access with conditional inside
|
||||
|
@ -49,19 +54,21 @@ file.ts(128,5): error TS2322: Type 'undefined' is not assignable to type 'T exte
|
|||
|
||||
function fun4bad<T, U extends keyof SomeInterfaceBad<unknown>>(x: T, y: U): SomeInterfaceBad<T>[U] {
|
||||
if (y === "prop1") {
|
||||
return x === 1 ? true : false;
|
||||
~~~~
|
||||
if (x === 1) return true;
|
||||
~~~~~~
|
||||
!!! error TS2322: Type 'true' is not assignable to type 'SomeInterfaceBad<T>[U]'.
|
||||
!!! error TS2322: Type 'true' is not assignable to type 'T extends 1 ? true : T extends 2 ? false : never'.
|
||||
~~~~~
|
||||
return false;
|
||||
~~~~~~
|
||||
!!! error TS2322: Type 'false' is not assignable to type 'SomeInterfaceBad<T>[U]'.
|
||||
!!! error TS2322: Type 'false' is not assignable to type 'T extends 1 ? true : T extends 2 ? false : never'.
|
||||
}
|
||||
return x ? 1 : 2;
|
||||
~
|
||||
if (x) return 1;
|
||||
~~~~~~
|
||||
!!! error TS2322: Type '1' is not assignable to type 'SomeInterfaceBad<T>[U]'.
|
||||
!!! error TS2322: Type '1' is not assignable to type 'T extends true ? 1 : T extends false ? 2 : never'.
|
||||
~
|
||||
return 2;
|
||||
~~~~~~
|
||||
!!! error TS2322: Type '2' is not assignable to type 'SomeInterfaceBad<T>[U]'.
|
||||
!!! error TS2322: Type '2' is not assignable to type 'T extends true ? 1 : T extends false ? 2 : never'.
|
||||
}
|
||||
|
@ -74,9 +81,11 @@ file.ts(128,5): error TS2322: Type 'undefined' is not assignable to type 'T exte
|
|||
|
||||
function fun4good<T extends boolean, U extends keyof SomeInterfaceGood<unknown>>(x: T, y: U): SomeInterfaceGood<T>[U] {
|
||||
if (y === "prop1") {
|
||||
return x ? 2 : 1;
|
||||
if (x) return 2;
|
||||
return 1;
|
||||
}
|
||||
return x ? 1 : 2;
|
||||
if (x) return 1;
|
||||
return 2;
|
||||
}
|
||||
|
||||
// Indexed access with indexed access inside - OK, narrows
|
||||
|
@ -131,10 +140,11 @@ file.ts(128,5): error TS2322: Type 'undefined' is not assignable to type 'T exte
|
|||
|
||||
// Detection of type parameter reference in presence of typeof
|
||||
function fun2<T extends boolean>(x: T, y: typeof x): T extends true ? 1 : T extends false ? 2 : never {
|
||||
return x ? 1 : 2;
|
||||
~
|
||||
if (x) return 1;
|
||||
~~~~~~
|
||||
!!! error TS2322: Type '1' is not assignable to type 'T extends true ? 1 : T extends false ? 2 : never'.
|
||||
~
|
||||
return 2;
|
||||
~~~~~~
|
||||
!!! error TS2322: Type '2' is not assignable to type 'T extends true ? 1 : T extends false ? 2 : never'.
|
||||
}
|
||||
|
||||
|
@ -143,7 +153,7 @@ file.ts(128,5): error TS2322: Type 'undefined' is not assignable to type 'T exte
|
|||
~~~~~~~~~
|
||||
!!! error TS2322: Type '1 | 2' is not assignable to type 'T extends true ? 1 : T extends false ? 2 : never'.
|
||||
!!! error TS2322: Type '1' is not assignable to type 'T extends true ? 1 : T extends false ? 2 : never'.
|
||||
!!! related TS6502 file.ts:98:13: The expected type comes from the return type of this signature.
|
||||
!!! related TS6502 file.ts:108:13: The expected type comes from the return type of this signature.
|
||||
|
||||
|
||||
// Circular conditionals
|
||||
|
|
|
@ -16,23 +16,16 @@ function outer<T extends boolean>(x: T): number {
|
|||
>T : Symbol(T, Decl(file.ts, 1, 15))
|
||||
>T : Symbol(T, Decl(file.ts, 1, 15))
|
||||
|
||||
return x ? 1 : 2;
|
||||
if (x) return 1;
|
||||
>x : Symbol(x, Decl(file.ts, 1, 34))
|
||||
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
|
||||
// Overloads
|
||||
function fun6<T extends boolean>(x: T, y: string): T extends true ? string : T extends false ? 2 : never;
|
||||
>fun6 : Symbol(fun6, Decl(file.ts, 7, 1), Decl(file.ts, 10, 105), Decl(file.ts, 11, 103), Decl(file.ts, 12, 42))
|
||||
>T : Symbol(T, Decl(file.ts, 10, 14))
|
||||
>x : Symbol(x, Decl(file.ts, 10, 33))
|
||||
>T : Symbol(T, Decl(file.ts, 10, 14))
|
||||
>y : Symbol(y, Decl(file.ts, 10, 38))
|
||||
>T : Symbol(T, Decl(file.ts, 10, 14))
|
||||
>T : Symbol(T, Decl(file.ts, 10, 14))
|
||||
|
||||
function fun6<T extends boolean>(x: T, y: undefined): T extends true ? 1 : T extends false ? 2 : never;
|
||||
>fun6 : Symbol(fun6, Decl(file.ts, 7, 1), Decl(file.ts, 10, 105), Decl(file.ts, 11, 103), Decl(file.ts, 12, 42))
|
||||
>fun6 : Symbol(fun6, Decl(file.ts, 8, 1), Decl(file.ts, 11, 105), Decl(file.ts, 12, 103), Decl(file.ts, 13, 42))
|
||||
>T : Symbol(T, Decl(file.ts, 11, 14))
|
||||
>x : Symbol(x, Decl(file.ts, 11, 33))
|
||||
>T : Symbol(T, Decl(file.ts, 11, 14))
|
||||
|
@ -40,148 +33,171 @@ function fun6<T extends boolean>(x: T, y: undefined): T extends true ? 1 : T ext
|
|||
>T : Symbol(T, Decl(file.ts, 11, 14))
|
||||
>T : Symbol(T, Decl(file.ts, 11, 14))
|
||||
|
||||
function fun6<T extends boolean>(x: T, y: undefined): T extends true ? 1 : T extends false ? 2 : never;
|
||||
>fun6 : Symbol(fun6, Decl(file.ts, 8, 1), Decl(file.ts, 11, 105), Decl(file.ts, 12, 103), Decl(file.ts, 13, 42))
|
||||
>T : Symbol(T, Decl(file.ts, 12, 14))
|
||||
>x : Symbol(x, Decl(file.ts, 12, 33))
|
||||
>T : Symbol(T, Decl(file.ts, 12, 14))
|
||||
>y : Symbol(y, Decl(file.ts, 12, 38))
|
||||
>T : Symbol(T, Decl(file.ts, 12, 14))
|
||||
>T : Symbol(T, Decl(file.ts, 12, 14))
|
||||
|
||||
function fun6(x: boolean): 1 | 2 | string;
|
||||
>fun6 : Symbol(fun6, Decl(file.ts, 7, 1), Decl(file.ts, 10, 105), Decl(file.ts, 11, 103), Decl(file.ts, 12, 42))
|
||||
>x : Symbol(x, Decl(file.ts, 12, 14))
|
||||
>fun6 : Symbol(fun6, Decl(file.ts, 8, 1), Decl(file.ts, 11, 105), Decl(file.ts, 12, 103), Decl(file.ts, 13, 42))
|
||||
>x : Symbol(x, Decl(file.ts, 13, 14))
|
||||
|
||||
function fun6<T extends boolean>(x: T, y?: string): T extends true ? 1 | string : T extends false ? 2 : never {
|
||||
>fun6 : Symbol(fun6, Decl(file.ts, 7, 1), Decl(file.ts, 10, 105), Decl(file.ts, 11, 103), Decl(file.ts, 12, 42))
|
||||
>T : Symbol(T, Decl(file.ts, 13, 14))
|
||||
>x : Symbol(x, Decl(file.ts, 13, 33))
|
||||
>T : Symbol(T, Decl(file.ts, 13, 14))
|
||||
>y : Symbol(y, Decl(file.ts, 13, 38))
|
||||
>T : Symbol(T, Decl(file.ts, 13, 14))
|
||||
>T : Symbol(T, Decl(file.ts, 13, 14))
|
||||
>fun6 : Symbol(fun6, Decl(file.ts, 8, 1), Decl(file.ts, 11, 105), Decl(file.ts, 12, 103), Decl(file.ts, 13, 42))
|
||||
>T : Symbol(T, Decl(file.ts, 14, 14))
|
||||
>x : Symbol(x, Decl(file.ts, 14, 33))
|
||||
>T : Symbol(T, Decl(file.ts, 14, 14))
|
||||
>y : Symbol(y, Decl(file.ts, 14, 38))
|
||||
>T : Symbol(T, Decl(file.ts, 14, 14))
|
||||
>T : Symbol(T, Decl(file.ts, 14, 14))
|
||||
|
||||
return x ? y !== undefined ? y : 1 : 2;
|
||||
>x : Symbol(x, Decl(file.ts, 13, 33))
|
||||
>y : Symbol(y, Decl(file.ts, 13, 38))
|
||||
if (x) {
|
||||
>x : Symbol(x, Decl(file.ts, 14, 33))
|
||||
|
||||
if (y !== undefined) return y;
|
||||
>y : Symbol(y, Decl(file.ts, 14, 38))
|
||||
>undefined : Symbol(undefined)
|
||||
>y : Symbol(y, Decl(file.ts, 13, 38))
|
||||
>y : Symbol(y, Decl(file.ts, 14, 38))
|
||||
|
||||
return 1;
|
||||
}
|
||||
return 2;
|
||||
}
|
||||
|
||||
// Indexed access with conditional inside
|
||||
|
||||
// DOESN'T NARROW the nested conditional type of wrong shape
|
||||
interface SomeInterfaceBad<T> {
|
||||
>SomeInterfaceBad : Symbol(SomeInterfaceBad, Decl(file.ts, 15, 1))
|
||||
>T : Symbol(T, Decl(file.ts, 20, 27))
|
||||
>SomeInterfaceBad : Symbol(SomeInterfaceBad, Decl(file.ts, 20, 1))
|
||||
>T : Symbol(T, Decl(file.ts, 25, 27))
|
||||
|
||||
prop1: T extends 1 ? true : T extends 2 ? false : never;
|
||||
>prop1 : Symbol(SomeInterfaceBad.prop1, Decl(file.ts, 20, 31))
|
||||
>T : Symbol(T, Decl(file.ts, 20, 27))
|
||||
>T : Symbol(T, Decl(file.ts, 20, 27))
|
||||
>prop1 : Symbol(SomeInterfaceBad.prop1, Decl(file.ts, 25, 31))
|
||||
>T : Symbol(T, Decl(file.ts, 25, 27))
|
||||
>T : Symbol(T, Decl(file.ts, 25, 27))
|
||||
|
||||
prop2: T extends true ? 1 : T extends false ? 2 : never;
|
||||
>prop2 : Symbol(SomeInterfaceBad.prop2, Decl(file.ts, 21, 60))
|
||||
>T : Symbol(T, Decl(file.ts, 20, 27))
|
||||
>T : Symbol(T, Decl(file.ts, 20, 27))
|
||||
>prop2 : Symbol(SomeInterfaceBad.prop2, Decl(file.ts, 26, 60))
|
||||
>T : Symbol(T, Decl(file.ts, 25, 27))
|
||||
>T : Symbol(T, Decl(file.ts, 25, 27))
|
||||
}
|
||||
|
||||
function fun4bad<T, U extends keyof SomeInterfaceBad<unknown>>(x: T, y: U): SomeInterfaceBad<T>[U] {
|
||||
>fun4bad : Symbol(fun4bad, Decl(file.ts, 23, 1))
|
||||
>T : Symbol(T, Decl(file.ts, 25, 17))
|
||||
>U : Symbol(U, Decl(file.ts, 25, 19))
|
||||
>SomeInterfaceBad : Symbol(SomeInterfaceBad, Decl(file.ts, 15, 1))
|
||||
>x : Symbol(x, Decl(file.ts, 25, 63))
|
||||
>T : Symbol(T, Decl(file.ts, 25, 17))
|
||||
>y : Symbol(y, Decl(file.ts, 25, 68))
|
||||
>U : Symbol(U, Decl(file.ts, 25, 19))
|
||||
>SomeInterfaceBad : Symbol(SomeInterfaceBad, Decl(file.ts, 15, 1))
|
||||
>T : Symbol(T, Decl(file.ts, 25, 17))
|
||||
>U : Symbol(U, Decl(file.ts, 25, 19))
|
||||
>fun4bad : Symbol(fun4bad, Decl(file.ts, 28, 1))
|
||||
>T : Symbol(T, Decl(file.ts, 30, 17))
|
||||
>U : Symbol(U, Decl(file.ts, 30, 19))
|
||||
>SomeInterfaceBad : Symbol(SomeInterfaceBad, Decl(file.ts, 20, 1))
|
||||
>x : Symbol(x, Decl(file.ts, 30, 63))
|
||||
>T : Symbol(T, Decl(file.ts, 30, 17))
|
||||
>y : Symbol(y, Decl(file.ts, 30, 68))
|
||||
>U : Symbol(U, Decl(file.ts, 30, 19))
|
||||
>SomeInterfaceBad : Symbol(SomeInterfaceBad, Decl(file.ts, 20, 1))
|
||||
>T : Symbol(T, Decl(file.ts, 30, 17))
|
||||
>U : Symbol(U, Decl(file.ts, 30, 19))
|
||||
|
||||
if (y === "prop1") {
|
||||
>y : Symbol(y, Decl(file.ts, 25, 68))
|
||||
>y : Symbol(y, Decl(file.ts, 30, 68))
|
||||
|
||||
return x === 1 ? true : false;
|
||||
>x : Symbol(x, Decl(file.ts, 25, 63))
|
||||
if (x === 1) return true;
|
||||
>x : Symbol(x, Decl(file.ts, 30, 63))
|
||||
|
||||
return false;
|
||||
}
|
||||
return x ? 1 : 2;
|
||||
>x : Symbol(x, Decl(file.ts, 25, 63))
|
||||
if (x) return 1;
|
||||
>x : Symbol(x, Decl(file.ts, 30, 63))
|
||||
|
||||
return 2;
|
||||
}
|
||||
|
||||
// Narrows nested conditional type of right shape
|
||||
interface SomeInterfaceGood<T> {
|
||||
>SomeInterfaceGood : Symbol(SomeInterfaceGood, Decl(file.ts, 30, 1))
|
||||
>T : Symbol(T, Decl(file.ts, 33, 28))
|
||||
>SomeInterfaceGood : Symbol(SomeInterfaceGood, Decl(file.ts, 37, 1))
|
||||
>T : Symbol(T, Decl(file.ts, 40, 28))
|
||||
|
||||
prop1: T extends true ? 2 : T extends false ? 1 : never;
|
||||
>prop1 : Symbol(SomeInterfaceGood.prop1, Decl(file.ts, 33, 32))
|
||||
>T : Symbol(T, Decl(file.ts, 33, 28))
|
||||
>T : Symbol(T, Decl(file.ts, 33, 28))
|
||||
>prop1 : Symbol(SomeInterfaceGood.prop1, Decl(file.ts, 40, 32))
|
||||
>T : Symbol(T, Decl(file.ts, 40, 28))
|
||||
>T : Symbol(T, Decl(file.ts, 40, 28))
|
||||
|
||||
prop2: T extends true ? 1 : T extends false ? 2 : never;
|
||||
>prop2 : Symbol(SomeInterfaceGood.prop2, Decl(file.ts, 34, 60))
|
||||
>T : Symbol(T, Decl(file.ts, 33, 28))
|
||||
>T : Symbol(T, Decl(file.ts, 33, 28))
|
||||
>prop2 : Symbol(SomeInterfaceGood.prop2, Decl(file.ts, 41, 60))
|
||||
>T : Symbol(T, Decl(file.ts, 40, 28))
|
||||
>T : Symbol(T, Decl(file.ts, 40, 28))
|
||||
}
|
||||
|
||||
function fun4good<T extends boolean, U extends keyof SomeInterfaceGood<unknown>>(x: T, y: U): SomeInterfaceGood<T>[U] {
|
||||
>fun4good : Symbol(fun4good, Decl(file.ts, 36, 1))
|
||||
>T : Symbol(T, Decl(file.ts, 38, 18))
|
||||
>U : Symbol(U, Decl(file.ts, 38, 36))
|
||||
>SomeInterfaceGood : Symbol(SomeInterfaceGood, Decl(file.ts, 30, 1))
|
||||
>x : Symbol(x, Decl(file.ts, 38, 81))
|
||||
>T : Symbol(T, Decl(file.ts, 38, 18))
|
||||
>y : Symbol(y, Decl(file.ts, 38, 86))
|
||||
>U : Symbol(U, Decl(file.ts, 38, 36))
|
||||
>SomeInterfaceGood : Symbol(SomeInterfaceGood, Decl(file.ts, 30, 1))
|
||||
>T : Symbol(T, Decl(file.ts, 38, 18))
|
||||
>U : Symbol(U, Decl(file.ts, 38, 36))
|
||||
>fun4good : Symbol(fun4good, Decl(file.ts, 43, 1))
|
||||
>T : Symbol(T, Decl(file.ts, 45, 18))
|
||||
>U : Symbol(U, Decl(file.ts, 45, 36))
|
||||
>SomeInterfaceGood : Symbol(SomeInterfaceGood, Decl(file.ts, 37, 1))
|
||||
>x : Symbol(x, Decl(file.ts, 45, 81))
|
||||
>T : Symbol(T, Decl(file.ts, 45, 18))
|
||||
>y : Symbol(y, Decl(file.ts, 45, 86))
|
||||
>U : Symbol(U, Decl(file.ts, 45, 36))
|
||||
>SomeInterfaceGood : Symbol(SomeInterfaceGood, Decl(file.ts, 37, 1))
|
||||
>T : Symbol(T, Decl(file.ts, 45, 18))
|
||||
>U : Symbol(U, Decl(file.ts, 45, 36))
|
||||
|
||||
if (y === "prop1") {
|
||||
>y : Symbol(y, Decl(file.ts, 38, 86))
|
||||
>y : Symbol(y, Decl(file.ts, 45, 86))
|
||||
|
||||
return x ? 2 : 1;
|
||||
>x : Symbol(x, Decl(file.ts, 38, 81))
|
||||
if (x) return 2;
|
||||
>x : Symbol(x, Decl(file.ts, 45, 81))
|
||||
|
||||
return 1;
|
||||
}
|
||||
return x ? 1 : 2;
|
||||
>x : Symbol(x, Decl(file.ts, 38, 81))
|
||||
if (x) return 1;
|
||||
>x : Symbol(x, Decl(file.ts, 45, 81))
|
||||
|
||||
return 2;
|
||||
}
|
||||
|
||||
// Indexed access with indexed access inside - OK, narrows
|
||||
interface BB {
|
||||
>BB : Symbol(BB, Decl(file.ts, 43, 1))
|
||||
>BB : Symbol(BB, Decl(file.ts, 52, 1))
|
||||
|
||||
"a": number;
|
||||
>"a" : Symbol(BB["a"], Decl(file.ts, 46, 14))
|
||||
>"a" : Symbol(BB["a"], Decl(file.ts, 55, 14))
|
||||
|
||||
"b": string;
|
||||
>"b" : Symbol(BB["b"], Decl(file.ts, 47, 16))
|
||||
>"b" : Symbol(BB["b"], Decl(file.ts, 56, 16))
|
||||
}
|
||||
|
||||
interface AA<T extends keyof BB> {
|
||||
>AA : Symbol(AA, Decl(file.ts, 49, 1))
|
||||
>T : Symbol(T, Decl(file.ts, 51, 13))
|
||||
>BB : Symbol(BB, Decl(file.ts, 43, 1))
|
||||
>AA : Symbol(AA, Decl(file.ts, 58, 1))
|
||||
>T : Symbol(T, Decl(file.ts, 60, 13))
|
||||
>BB : Symbol(BB, Decl(file.ts, 52, 1))
|
||||
|
||||
"c": BB[T];
|
||||
>"c" : Symbol(AA["c"], Decl(file.ts, 51, 34))
|
||||
>BB : Symbol(BB, Decl(file.ts, 43, 1))
|
||||
>T : Symbol(T, Decl(file.ts, 51, 13))
|
||||
>"c" : Symbol(AA["c"], Decl(file.ts, 60, 34))
|
||||
>BB : Symbol(BB, Decl(file.ts, 52, 1))
|
||||
>T : Symbol(T, Decl(file.ts, 60, 13))
|
||||
|
||||
"d": boolean,
|
||||
>"d" : Symbol(AA["d"], Decl(file.ts, 52, 15))
|
||||
>"d" : Symbol(AA["d"], Decl(file.ts, 61, 15))
|
||||
}
|
||||
|
||||
function reduction<T extends keyof BB, U extends keyof AA<any>>(x: T, y: U): AA<T>[U] {
|
||||
>reduction : Symbol(reduction, Decl(file.ts, 54, 1))
|
||||
>T : Symbol(T, Decl(file.ts, 56, 19))
|
||||
>BB : Symbol(BB, Decl(file.ts, 43, 1))
|
||||
>U : Symbol(U, Decl(file.ts, 56, 38))
|
||||
>AA : Symbol(AA, Decl(file.ts, 49, 1))
|
||||
>x : Symbol(x, Decl(file.ts, 56, 64))
|
||||
>T : Symbol(T, Decl(file.ts, 56, 19))
|
||||
>y : Symbol(y, Decl(file.ts, 56, 69))
|
||||
>U : Symbol(U, Decl(file.ts, 56, 38))
|
||||
>AA : Symbol(AA, Decl(file.ts, 49, 1))
|
||||
>T : Symbol(T, Decl(file.ts, 56, 19))
|
||||
>U : Symbol(U, Decl(file.ts, 56, 38))
|
||||
>reduction : Symbol(reduction, Decl(file.ts, 63, 1))
|
||||
>T : Symbol(T, Decl(file.ts, 65, 19))
|
||||
>BB : Symbol(BB, Decl(file.ts, 52, 1))
|
||||
>U : Symbol(U, Decl(file.ts, 65, 38))
|
||||
>AA : Symbol(AA, Decl(file.ts, 58, 1))
|
||||
>x : Symbol(x, Decl(file.ts, 65, 64))
|
||||
>T : Symbol(T, Decl(file.ts, 65, 19))
|
||||
>y : Symbol(y, Decl(file.ts, 65, 69))
|
||||
>U : Symbol(U, Decl(file.ts, 65, 38))
|
||||
>AA : Symbol(AA, Decl(file.ts, 58, 1))
|
||||
>T : Symbol(T, Decl(file.ts, 65, 19))
|
||||
>U : Symbol(U, Decl(file.ts, 65, 38))
|
||||
|
||||
if (x === "a" && y === "c") {
|
||||
>x : Symbol(x, Decl(file.ts, 56, 64))
|
||||
>y : Symbol(y, Decl(file.ts, 56, 69))
|
||||
>x : Symbol(x, Decl(file.ts, 65, 64))
|
||||
>y : Symbol(y, Decl(file.ts, 65, 69))
|
||||
|
||||
return 0; // Ok
|
||||
}
|
||||
|
@ -192,24 +208,24 @@ function reduction<T extends keyof BB, U extends keyof AA<any>>(x: T, y: U): AA<
|
|||
|
||||
// Conditional with indexed access inside - OK, narrows
|
||||
function fun5<T extends 1 | 2, U extends keyof BB>(x: T, y: U): T extends 1 ? BB[U] : T extends 2 ? boolean : never {
|
||||
>fun5 : Symbol(fun5, Decl(file.ts, 62, 1))
|
||||
>T : Symbol(T, Decl(file.ts, 65, 14))
|
||||
>U : Symbol(U, Decl(file.ts, 65, 30))
|
||||
>BB : Symbol(BB, Decl(file.ts, 43, 1))
|
||||
>x : Symbol(x, Decl(file.ts, 65, 51))
|
||||
>T : Symbol(T, Decl(file.ts, 65, 14))
|
||||
>y : Symbol(y, Decl(file.ts, 65, 56))
|
||||
>U : Symbol(U, Decl(file.ts, 65, 30))
|
||||
>T : Symbol(T, Decl(file.ts, 65, 14))
|
||||
>BB : Symbol(BB, Decl(file.ts, 43, 1))
|
||||
>U : Symbol(U, Decl(file.ts, 65, 30))
|
||||
>T : Symbol(T, Decl(file.ts, 65, 14))
|
||||
>fun5 : Symbol(fun5, Decl(file.ts, 71, 1))
|
||||
>T : Symbol(T, Decl(file.ts, 74, 14))
|
||||
>U : Symbol(U, Decl(file.ts, 74, 30))
|
||||
>BB : Symbol(BB, Decl(file.ts, 52, 1))
|
||||
>x : Symbol(x, Decl(file.ts, 74, 51))
|
||||
>T : Symbol(T, Decl(file.ts, 74, 14))
|
||||
>y : Symbol(y, Decl(file.ts, 74, 56))
|
||||
>U : Symbol(U, Decl(file.ts, 74, 30))
|
||||
>T : Symbol(T, Decl(file.ts, 74, 14))
|
||||
>BB : Symbol(BB, Decl(file.ts, 52, 1))
|
||||
>U : Symbol(U, Decl(file.ts, 74, 30))
|
||||
>T : Symbol(T, Decl(file.ts, 74, 14))
|
||||
|
||||
if (x === 1) {
|
||||
>x : Symbol(x, Decl(file.ts, 65, 51))
|
||||
>x : Symbol(x, Decl(file.ts, 74, 51))
|
||||
|
||||
if (y === "a") {
|
||||
>y : Symbol(y, Decl(file.ts, 65, 56))
|
||||
>y : Symbol(y, Decl(file.ts, 74, 56))
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -220,19 +236,19 @@ function fun5<T extends 1 | 2, U extends keyof BB>(x: T, y: U): T extends 1 ? BB
|
|||
|
||||
// `this` type parameter - Doesn't narrow
|
||||
abstract class SomeClass {
|
||||
>SomeClass : Symbol(SomeClass, Decl(file.ts, 73, 1))
|
||||
>SomeClass : Symbol(SomeClass, Decl(file.ts, 82, 1))
|
||||
|
||||
fun3(this: Sub1 | Sub2): this extends Sub1 ? 1 : this extends Sub2 ? 2 : never {
|
||||
>fun3 : Symbol(SomeClass.fun3, Decl(file.ts, 76, 26))
|
||||
>this : Symbol(this, Decl(file.ts, 77, 9))
|
||||
>Sub1 : Symbol(Sub1, Decl(file.ts, 83, 1))
|
||||
>Sub2 : Symbol(Sub2, Decl(file.ts, 86, 2))
|
||||
>Sub1 : Symbol(Sub1, Decl(file.ts, 83, 1))
|
||||
>Sub2 : Symbol(Sub2, Decl(file.ts, 86, 2))
|
||||
>fun3 : Symbol(SomeClass.fun3, Decl(file.ts, 85, 26))
|
||||
>this : Symbol(this, Decl(file.ts, 86, 9))
|
||||
>Sub1 : Symbol(Sub1, Decl(file.ts, 92, 1))
|
||||
>Sub2 : Symbol(Sub2, Decl(file.ts, 95, 2))
|
||||
>Sub1 : Symbol(Sub1, Decl(file.ts, 92, 1))
|
||||
>Sub2 : Symbol(Sub2, Decl(file.ts, 95, 2))
|
||||
|
||||
if (this instanceof Sub1) {
|
||||
>this : Symbol(this, Decl(file.ts, 77, 9))
|
||||
>Sub1 : Symbol(Sub1, Decl(file.ts, 83, 1))
|
||||
>this : Symbol(this, Decl(file.ts, 86, 9))
|
||||
>Sub1 : Symbol(Sub1, Decl(file.ts, 92, 1))
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@ -240,68 +256,70 @@ abstract class SomeClass {
|
|||
}
|
||||
}
|
||||
class Sub1 extends SomeClass {
|
||||
>Sub1 : Symbol(Sub1, Decl(file.ts, 83, 1))
|
||||
>SomeClass : Symbol(SomeClass, Decl(file.ts, 73, 1))
|
||||
>Sub1 : Symbol(Sub1, Decl(file.ts, 92, 1))
|
||||
>SomeClass : Symbol(SomeClass, Decl(file.ts, 82, 1))
|
||||
|
||||
#sub1!: symbol;
|
||||
>#sub1 : Symbol(Sub1.#sub1, Decl(file.ts, 84, 30))
|
||||
>#sub1 : Symbol(Sub1.#sub1, Decl(file.ts, 93, 30))
|
||||
|
||||
};
|
||||
class Sub2 extends SomeClass {
|
||||
>Sub2 : Symbol(Sub2, Decl(file.ts, 86, 2))
|
||||
>SomeClass : Symbol(SomeClass, Decl(file.ts, 73, 1))
|
||||
>Sub2 : Symbol(Sub2, Decl(file.ts, 95, 2))
|
||||
>SomeClass : Symbol(SomeClass, Decl(file.ts, 82, 1))
|
||||
|
||||
#sub2!: symbol;
|
||||
>#sub2 : Symbol(Sub2.#sub2, Decl(file.ts, 87, 30))
|
||||
>#sub2 : Symbol(Sub2.#sub2, Decl(file.ts, 96, 30))
|
||||
|
||||
};
|
||||
|
||||
// Detection of type parameter reference in presence of typeof
|
||||
function fun2<T extends boolean>(x: T, y: typeof x): T extends true ? 1 : T extends false ? 2 : never {
|
||||
>fun2 : Symbol(fun2, Decl(file.ts, 89, 2))
|
||||
>T : Symbol(T, Decl(file.ts, 92, 14))
|
||||
>x : Symbol(x, Decl(file.ts, 92, 33))
|
||||
>T : Symbol(T, Decl(file.ts, 92, 14))
|
||||
>y : Symbol(y, Decl(file.ts, 92, 38))
|
||||
>x : Symbol(x, Decl(file.ts, 92, 33))
|
||||
>T : Symbol(T, Decl(file.ts, 92, 14))
|
||||
>T : Symbol(T, Decl(file.ts, 92, 14))
|
||||
>fun2 : Symbol(fun2, Decl(file.ts, 98, 2))
|
||||
>T : Symbol(T, Decl(file.ts, 101, 14))
|
||||
>x : Symbol(x, Decl(file.ts, 101, 33))
|
||||
>T : Symbol(T, Decl(file.ts, 101, 14))
|
||||
>y : Symbol(y, Decl(file.ts, 101, 38))
|
||||
>x : Symbol(x, Decl(file.ts, 101, 33))
|
||||
>T : Symbol(T, Decl(file.ts, 101, 14))
|
||||
>T : Symbol(T, Decl(file.ts, 101, 14))
|
||||
|
||||
return x ? 1 : 2;
|
||||
>x : Symbol(x, Decl(file.ts, 92, 33))
|
||||
if (x) return 1;
|
||||
>x : Symbol(x, Decl(file.ts, 101, 33))
|
||||
|
||||
return 2;
|
||||
}
|
||||
|
||||
// Contextually-typed lambdas
|
||||
const fun1: <T extends boolean>(x: T) => T extends true ? 1 : T extends false ? 2 : never = (x) => x ? 1 : 2;
|
||||
>fun1 : Symbol(fun1, Decl(file.ts, 97, 5))
|
||||
>T : Symbol(T, Decl(file.ts, 97, 13))
|
||||
>x : Symbol(x, Decl(file.ts, 97, 32))
|
||||
>T : Symbol(T, Decl(file.ts, 97, 13))
|
||||
>T : Symbol(T, Decl(file.ts, 97, 13))
|
||||
>T : Symbol(T, Decl(file.ts, 97, 13))
|
||||
>x : Symbol(x, Decl(file.ts, 97, 93))
|
||||
>x : Symbol(x, Decl(file.ts, 97, 93))
|
||||
>fun1 : Symbol(fun1, Decl(file.ts, 107, 5))
|
||||
>T : Symbol(T, Decl(file.ts, 107, 13))
|
||||
>x : Symbol(x, Decl(file.ts, 107, 32))
|
||||
>T : Symbol(T, Decl(file.ts, 107, 13))
|
||||
>T : Symbol(T, Decl(file.ts, 107, 13))
|
||||
>T : Symbol(T, Decl(file.ts, 107, 13))
|
||||
>x : Symbol(x, Decl(file.ts, 107, 93))
|
||||
>x : Symbol(x, Decl(file.ts, 107, 93))
|
||||
|
||||
|
||||
// Circular conditionals
|
||||
type SomeCond<T> = T extends true ? 1 : T extends false ? SomeCond<T> : never;
|
||||
>SomeCond : Symbol(SomeCond, Decl(file.ts, 97, 109))
|
||||
>T : Symbol(T, Decl(file.ts, 101, 14))
|
||||
>T : Symbol(T, Decl(file.ts, 101, 14))
|
||||
>T : Symbol(T, Decl(file.ts, 101, 14))
|
||||
>SomeCond : Symbol(SomeCond, Decl(file.ts, 97, 109))
|
||||
>T : Symbol(T, Decl(file.ts, 101, 14))
|
||||
>SomeCond : Symbol(SomeCond, Decl(file.ts, 107, 109))
|
||||
>T : Symbol(T, Decl(file.ts, 111, 14))
|
||||
>T : Symbol(T, Decl(file.ts, 111, 14))
|
||||
>T : Symbol(T, Decl(file.ts, 111, 14))
|
||||
>SomeCond : Symbol(SomeCond, Decl(file.ts, 107, 109))
|
||||
>T : Symbol(T, Decl(file.ts, 111, 14))
|
||||
|
||||
function f7<T extends boolean>(x: T): SomeCond<T> {
|
||||
>f7 : Symbol(f7, Decl(file.ts, 101, 78))
|
||||
>T : Symbol(T, Decl(file.ts, 103, 12))
|
||||
>x : Symbol(x, Decl(file.ts, 103, 31))
|
||||
>T : Symbol(T, Decl(file.ts, 103, 12))
|
||||
>SomeCond : Symbol(SomeCond, Decl(file.ts, 97, 109))
|
||||
>T : Symbol(T, Decl(file.ts, 103, 12))
|
||||
>f7 : Symbol(f7, Decl(file.ts, 111, 78))
|
||||
>T : Symbol(T, Decl(file.ts, 113, 12))
|
||||
>x : Symbol(x, Decl(file.ts, 113, 31))
|
||||
>T : Symbol(T, Decl(file.ts, 113, 12))
|
||||
>SomeCond : Symbol(SomeCond, Decl(file.ts, 107, 109))
|
||||
>T : Symbol(T, Decl(file.ts, 113, 12))
|
||||
|
||||
if (x) {
|
||||
>x : Symbol(x, Decl(file.ts, 103, 31))
|
||||
>x : Symbol(x, Decl(file.ts, 113, 31))
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@ -310,28 +328,28 @@ function f7<T extends boolean>(x: T): SomeCond<T> {
|
|||
|
||||
// Composite instantiation of conditional type
|
||||
type OtherCond<T> = T extends 1 ? "one" : T extends 2 ? "two" : T extends 3 ? "three" : T extends 4 ? "four" : never;
|
||||
>OtherCond : Symbol(OtherCond, Decl(file.ts, 108, 1))
|
||||
>T : Symbol(T, Decl(file.ts, 111, 15))
|
||||
>T : Symbol(T, Decl(file.ts, 111, 15))
|
||||
>T : Symbol(T, Decl(file.ts, 111, 15))
|
||||
>T : Symbol(T, Decl(file.ts, 111, 15))
|
||||
>T : Symbol(T, Decl(file.ts, 111, 15))
|
||||
>OtherCond : Symbol(OtherCond, Decl(file.ts, 118, 1))
|
||||
>T : Symbol(T, Decl(file.ts, 121, 15))
|
||||
>T : Symbol(T, Decl(file.ts, 121, 15))
|
||||
>T : Symbol(T, Decl(file.ts, 121, 15))
|
||||
>T : Symbol(T, Decl(file.ts, 121, 15))
|
||||
>T : Symbol(T, Decl(file.ts, 121, 15))
|
||||
|
||||
function f8<U extends 1 | 2, V extends 3 | 4>(x: U, y: V): OtherCond<U | V> {
|
||||
>f8 : Symbol(f8, Decl(file.ts, 111, 117))
|
||||
>U : Symbol(U, Decl(file.ts, 113, 12))
|
||||
>V : Symbol(V, Decl(file.ts, 113, 28))
|
||||
>x : Symbol(x, Decl(file.ts, 113, 46))
|
||||
>U : Symbol(U, Decl(file.ts, 113, 12))
|
||||
>y : Symbol(y, Decl(file.ts, 113, 51))
|
||||
>V : Symbol(V, Decl(file.ts, 113, 28))
|
||||
>OtherCond : Symbol(OtherCond, Decl(file.ts, 108, 1))
|
||||
>U : Symbol(U, Decl(file.ts, 113, 12))
|
||||
>V : Symbol(V, Decl(file.ts, 113, 28))
|
||||
>f8 : Symbol(f8, Decl(file.ts, 121, 117))
|
||||
>U : Symbol(U, Decl(file.ts, 123, 12))
|
||||
>V : Symbol(V, Decl(file.ts, 123, 28))
|
||||
>x : Symbol(x, Decl(file.ts, 123, 46))
|
||||
>U : Symbol(U, Decl(file.ts, 123, 12))
|
||||
>y : Symbol(y, Decl(file.ts, 123, 51))
|
||||
>V : Symbol(V, Decl(file.ts, 123, 28))
|
||||
>OtherCond : Symbol(OtherCond, Decl(file.ts, 118, 1))
|
||||
>U : Symbol(U, Decl(file.ts, 123, 12))
|
||||
>V : Symbol(V, Decl(file.ts, 123, 28))
|
||||
|
||||
if (x === 1 && y === 3) {
|
||||
>x : Symbol(x, Decl(file.ts, 113, 46))
|
||||
>y : Symbol(y, Decl(file.ts, 113, 51))
|
||||
>x : Symbol(x, Decl(file.ts, 123, 46))
|
||||
>y : Symbol(y, Decl(file.ts, 123, 51))
|
||||
|
||||
return "one";
|
||||
}
|
||||
|
@ -339,21 +357,21 @@ function f8<U extends 1 | 2, V extends 3 | 4>(x: U, y: V): OtherCond<U | V> {
|
|||
|
||||
// Conditionals with `infer` - will not narrow, it is not safe to infer from the narrowed type into an `infer` type parameter
|
||||
function f9<T extends "a"[] | "b"[] | number>(x: T): T extends Array<infer P> ? P : T extends number ? undefined : never {
|
||||
>f9 : Symbol(f9, Decl(file.ts, 117, 1))
|
||||
>T : Symbol(T, Decl(file.ts, 120, 12))
|
||||
>x : Symbol(x, Decl(file.ts, 120, 46))
|
||||
>T : Symbol(T, Decl(file.ts, 120, 12))
|
||||
>T : Symbol(T, Decl(file.ts, 120, 12))
|
||||
>f9 : Symbol(f9, Decl(file.ts, 127, 1))
|
||||
>T : Symbol(T, Decl(file.ts, 130, 12))
|
||||
>x : Symbol(x, Decl(file.ts, 130, 46))
|
||||
>T : Symbol(T, Decl(file.ts, 130, 12))
|
||||
>T : Symbol(T, Decl(file.ts, 130, 12))
|
||||
>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 4 more)
|
||||
>P : Symbol(P, Decl(file.ts, 120, 74))
|
||||
>P : Symbol(P, Decl(file.ts, 120, 74))
|
||||
>T : Symbol(T, Decl(file.ts, 120, 12))
|
||||
>P : Symbol(P, Decl(file.ts, 130, 74))
|
||||
>P : Symbol(P, Decl(file.ts, 130, 74))
|
||||
>T : Symbol(T, Decl(file.ts, 130, 12))
|
||||
|
||||
if (Array.isArray(x)) {
|
||||
>Array.isArray : Symbol(ArrayConstructor.isArray, Decl(lib.es5.d.ts, --, --))
|
||||
>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 4 more)
|
||||
>isArray : Symbol(ArrayConstructor.isArray, Decl(lib.es5.d.ts, --, --))
|
||||
>x : Symbol(x, Decl(file.ts, 120, 46))
|
||||
>x : Symbol(x, Decl(file.ts, 130, 46))
|
||||
|
||||
// If we allowed narrowing of the conditional return type, when resolving the conditional `T & ("a"[] | "b"[]) extends Array<infer P> ? P : ...`,
|
||||
// we could infer `"a" | "b"` for `P`, and allow "a" to be returned. However, when calling `f10`, `T` could be instantiated with `"b"[]`, and the return type would be `"b"`,
|
||||
|
|
|
@ -25,13 +25,13 @@ function outer<T extends boolean>(x: T): number {
|
|||
>false : false
|
||||
> : ^^^^^
|
||||
|
||||
return x ? 1 : 2;
|
||||
>x ? 1 : 2 : 1 | 2
|
||||
> : ^^^^^
|
||||
if (x) return 1;
|
||||
>x : T
|
||||
> : ^
|
||||
>1 : 1
|
||||
> : ^
|
||||
|
||||
return 2;
|
||||
>2 : 2
|
||||
> : ^
|
||||
}
|
||||
|
@ -80,13 +80,11 @@ function fun6<T extends boolean>(x: T, y?: string): T extends true ? 1 | string
|
|||
>false : false
|
||||
> : ^^^^^
|
||||
|
||||
return x ? y !== undefined ? y : 1 : 2;
|
||||
>x ? y !== undefined ? y : 1 : 2 : string | 1 | 2
|
||||
> : ^^^^^^^^^^^^^^
|
||||
if (x) {
|
||||
>x : T
|
||||
> : ^
|
||||
>y !== undefined ? y : 1 : string | 1
|
||||
> : ^^^^^^^^^^
|
||||
|
||||
if (y !== undefined) return y;
|
||||
>y !== undefined : boolean
|
||||
> : ^^^^^^^
|
||||
>y : string | undefined
|
||||
|
@ -95,8 +93,12 @@ function fun6<T extends boolean>(x: T, y?: string): T extends true ? 1 | string
|
|||
> : ^^^^^^^^^
|
||||
>y : string
|
||||
> : ^^^^^^
|
||||
|
||||
return 1;
|
||||
>1 : 1
|
||||
> : ^
|
||||
}
|
||||
return 2;
|
||||
>2 : 2
|
||||
> : ^
|
||||
}
|
||||
|
@ -138,9 +140,7 @@ function fun4bad<T, U extends keyof SomeInterfaceBad<unknown>>(x: T, y: U): Some
|
|||
>"prop1" : "prop1"
|
||||
> : ^^^^^^^
|
||||
|
||||
return x === 1 ? true : false;
|
||||
>x === 1 ? true : false : boolean
|
||||
> : ^^^^^^^
|
||||
if (x === 1) return true;
|
||||
>x === 1 : boolean
|
||||
> : ^^^^^^^
|
||||
>x : T
|
||||
|
@ -149,16 +149,18 @@ function fun4bad<T, U extends keyof SomeInterfaceBad<unknown>>(x: T, y: U): Some
|
|||
> : ^
|
||||
>true : true
|
||||
> : ^^^^
|
||||
|
||||
return false;
|
||||
>false : false
|
||||
> : ^^^^^
|
||||
}
|
||||
return x ? 1 : 2;
|
||||
>x ? 1 : 2 : 1 | 2
|
||||
> : ^^^^^
|
||||
if (x) return 1;
|
||||
>x : T
|
||||
> : ^
|
||||
>1 : 1
|
||||
> : ^
|
||||
|
||||
return 2;
|
||||
>2 : 2
|
||||
> : ^
|
||||
}
|
||||
|
@ -198,23 +200,23 @@ function fun4good<T extends boolean, U extends keyof SomeInterfaceGood<unknown>>
|
|||
>"prop1" : "prop1"
|
||||
> : ^^^^^^^
|
||||
|
||||
return x ? 2 : 1;
|
||||
>x ? 2 : 1 : 1 | 2
|
||||
> : ^^^^^
|
||||
if (x) return 2;
|
||||
>x : T
|
||||
> : ^
|
||||
>2 : 2
|
||||
> : ^
|
||||
|
||||
return 1;
|
||||
>1 : 1
|
||||
> : ^
|
||||
}
|
||||
return x ? 1 : 2;
|
||||
>x ? 1 : 2 : 1 | 2
|
||||
> : ^^^^^
|
||||
if (x) return 1;
|
||||
>x : T
|
||||
> : ^
|
||||
>1 : 1
|
||||
> : ^
|
||||
|
||||
return 2;
|
||||
>2 : 2
|
||||
> : ^
|
||||
}
|
||||
|
@ -380,13 +382,13 @@ function fun2<T extends boolean>(x: T, y: typeof x): T extends true ? 1 : T exte
|
|||
>false : false
|
||||
> : ^^^^^
|
||||
|
||||
return x ? 1 : 2;
|
||||
>x ? 1 : 2 : 1 | 2
|
||||
> : ^^^^^
|
||||
if (x) return 1;
|
||||
>x : T
|
||||
> : ^
|
||||
>1 : 1
|
||||
> : ^
|
||||
|
||||
return 2;
|
||||
>2 : 2
|
||||
> : ^
|
||||
}
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
file.js(22,12): error TS2322: Type '1 | 2' is not assignable to type 'T extends true ? 1 : T extends false ? 2 : never'.
|
||||
Type '1' is not assignable to type 'T extends true ? 1 : T extends false ? 2 : never'.
|
||||
|
||||
|
||||
==== file.js (1 errors) ====
|
||||
/** @type {Map<string, string>} */
|
||||
const sources = new Map();
|
||||
/**
|
||||
|
||||
* @param {string=} type the type of source that should be generated
|
||||
* @returns {String}
|
||||
*/
|
||||
function source(type = "javascript") {
|
||||
return /** @type {String} */ (
|
||||
type
|
||||
? sources.get(type)
|
||||
: sources.get("some other thing")
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @template {boolean} T
|
||||
* @param {T} b
|
||||
* @returns {T extends true ? 1 : T extends false ? 2 : never}
|
||||
*/
|
||||
function simple(b) {
|
||||
return b ? 1 : 2;
|
||||
~~~~~~~~~
|
||||
!!! error TS2322: Type '1 | 2' is not assignable to type 'T extends true ? 1 : T extends false ? 2 : never'.
|
||||
!!! error TS2322: Type '1' is not assignable to type 'T extends true ? 1 : T extends false ? 2 : never'.
|
||||
}
|
|
@ -186,7 +186,8 @@ interface Aa {
|
|||
|
||||
function trivialConditional<T extends 1 | 2 | 3>(x: T): Aa[T] {
|
||||
if (x !== 1) {
|
||||
return x === 2 ? "" : true;
|
||||
if (x === 2) return "";
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
|
@ -195,13 +196,13 @@ function trivialConditional<T extends 1 | 2 | 3>(x: T): Aa[T] {
|
|||
|
||||
function conditional<T extends boolean>(x: T):
|
||||
T extends true ? 1 : T extends false ? 2 : never {
|
||||
return x ? 1 : 2; // Ok
|
||||
return x ? 1 : 2;
|
||||
}
|
||||
|
||||
function contextualConditional<T extends "a" | "b">(
|
||||
x: T
|
||||
): T extends "a" ? "a" : T extends "b" ? number : never {
|
||||
return x === "a" ? x : parseInt(x); // Ok
|
||||
return x === "a" ? x : parseInt(x);
|
||||
}
|
||||
|
||||
function conditionalWithError<T extends "a" | "b">(
|
||||
|
|
|
@ -222,15 +222,16 @@ function mapDateForAPI(x) {
|
|||
* @returns {HelperCond<T, string, { start: Date, end: Date }, undefined, { start: Date, end: undefined }>}
|
||||
*/
|
||||
function transformDatesForAPI(start, end) {
|
||||
return end !== undefined ?
|
||||
{
|
||||
if (end !== undefined) {
|
||||
return {
|
||||
start: mapDateForAPI(start),
|
||||
end: mapDateForAPI(end),
|
||||
} :
|
||||
{
|
||||
start: mapDateForAPI(start),
|
||||
end: undefined
|
||||
};
|
||||
}
|
||||
return {
|
||||
start: mapDateForAPI(start),
|
||||
end: undefined
|
||||
};
|
||||
}
|
||||
|
||||
// File: Rocket.Chat/packages/agenda/src/Agenda.ts
|
||||
|
|
|
@ -163,15 +163,16 @@ export function transformDatesForAPI<T extends string | undefined>(
|
|||
start: string,
|
||||
end?: T
|
||||
): HelperCond<T, string, { start: Date, end: Date }, undefined, { start: Date, end: undefined }> {
|
||||
return end !== undefined ? // Ok
|
||||
{
|
||||
if (end !== undefined) {
|
||||
return {
|
||||
start: mapDateForAPI(start),
|
||||
end: mapDateForAPI(end),
|
||||
} :
|
||||
{
|
||||
start: mapDateForAPI(start),
|
||||
end: undefined
|
||||
};
|
||||
}
|
||||
return {
|
||||
start: mapDateForAPI(start),
|
||||
end: undefined
|
||||
};
|
||||
}
|
||||
|
||||
// File: Rocket.Chat/packages/agenda/src/Agenda.ts
|
||||
|
|
|
@ -10,7 +10,8 @@ function outer<T extends boolean>(x: T): number {
|
|||
return inner();
|
||||
|
||||
function inner(): T extends true ? 1 : T extends false ? 2 : never {
|
||||
return x ? 1 : 2;
|
||||
if (x) return 1;
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -19,7 +20,11 @@ function fun6<T extends boolean>(x: T, y: string): T extends true ? string : T e
|
|||
function fun6<T extends boolean>(x: T, y: undefined): T extends true ? 1 : T extends false ? 2 : never;
|
||||
function fun6(x: boolean): 1 | 2 | string;
|
||||
function fun6<T extends boolean>(x: T, y?: string): T extends true ? 1 | string : T extends false ? 2 : never {
|
||||
return x ? y !== undefined ? y : 1 : 2;
|
||||
if (x) {
|
||||
if (y !== undefined) return y;
|
||||
return 1;
|
||||
}
|
||||
return 2;
|
||||
}
|
||||
|
||||
// Indexed access with conditional inside
|
||||
|
@ -32,9 +37,11 @@ interface SomeInterfaceBad<T> {
|
|||
|
||||
function fun4bad<T, U extends keyof SomeInterfaceBad<unknown>>(x: T, y: U): SomeInterfaceBad<T>[U] {
|
||||
if (y === "prop1") {
|
||||
return x === 1 ? true : false;
|
||||
if (x === 1) return true;
|
||||
return false;
|
||||
}
|
||||
return x ? 1 : 2;
|
||||
if (x) return 1;
|
||||
return 2;
|
||||
}
|
||||
|
||||
// Narrows nested conditional type of right shape
|
||||
|
@ -45,9 +52,11 @@ interface SomeInterfaceGood<T> {
|
|||
|
||||
function fun4good<T extends boolean, U extends keyof SomeInterfaceGood<unknown>>(x: T, y: U): SomeInterfaceGood<T>[U] {
|
||||
if (y === "prop1") {
|
||||
return x ? 2 : 1;
|
||||
if (x) return 2;
|
||||
return 1;
|
||||
}
|
||||
return x ? 1 : 2;
|
||||
if (x) return 1;
|
||||
return 2;
|
||||
}
|
||||
|
||||
// Indexed access with indexed access inside - OK, narrows
|
||||
|
@ -98,7 +107,8 @@ class Sub2 extends SomeClass {
|
|||
|
||||
// Detection of type parameter reference in presence of typeof
|
||||
function fun2<T extends boolean>(x: T, y: typeof x): T extends true ? 1 : T extends false ? 2 : never {
|
||||
return x ? 1 : 2;
|
||||
if (x) return 1;
|
||||
return 2;
|
||||
}
|
||||
|
||||
// Contextually-typed lambdas
|
||||
|
|
Загрузка…
Ссылка в новой задаче