diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 5c94dde5cc597..9fc4b465d96d9 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -101,6 +101,7 @@ import { getImmediatelyInvokedFunctionExpression, getJSDocHost, getJSDocTypeTag, + getLambdaArgument, getLeftmostAccessExpression, getNameOfDeclaration, getNameOrArgument, @@ -318,6 +319,7 @@ import { unreachableCodeIsError, unusedLabelIsError, VariableDeclaration, + walkUpParenthesizedExpressions, WhileStatement, WithStatement, } from "./_namespaces/ts.js"; @@ -545,6 +547,7 @@ function createBinder(): (file: SourceFile, options: CompilerOptions) => void { var activeLabelList: ActiveLabel | undefined; var hasExplicitReturn: boolean; var hasFlowEffects: boolean; + var hasFlowMutation: boolean; // state used for emit helpers var emitFlags: NodeFlags; @@ -624,6 +627,7 @@ function createBinder(): (file: SourceFile, options: CompilerOptions) => void { activeLabelList = undefined; hasExplicitReturn = false; hasFlowEffects = false; + hasFlowMutation = false; inAssignmentPattern = false; emitFlags = NodeFlags.None; } @@ -1010,12 +1014,11 @@ function createBinder(): (file: SourceFile, options: CompilerOptions) => void { const saveExceptionTarget = currentExceptionTarget; const saveActiveLabelList = activeLabelList; const saveHasExplicitReturn = hasExplicitReturn; - const isImmediatelyInvoked = ( - containerFlags & ContainerFlags.IsFunctionExpression && + const isRegularFunctionExpression = containerFlags & ContainerFlags.IsFunctionExpression && !hasSyntacticModifier(node, ModifierFlags.Async) && - !(node as FunctionLikeDeclaration).asteriskToken && - !!getImmediatelyInvokedFunctionExpression(node) - ) || node.kind === SyntaxKind.ClassStaticBlockDeclaration; + !(node as FunctionLikeDeclaration).asteriskToken; + const isImmediatelyInvoked = isRegularFunctionExpression && !!getImmediatelyInvokedFunctionExpression(node) || node.kind === SyntaxKind.ClassStaticBlockDeclaration; + const isLambdaArgument = isRegularFunctionExpression && walkUpParenthesizedExpressions(node.parent).kind === SyntaxKind.CallExpression; // A non-async, non-generator IIFE is considered part of the containing control flow. Return statements behave // similarly to break statements that exit to a label just past the statement body. if (!isImmediatelyInvoked) { @@ -1026,7 +1029,7 @@ function createBinder(): (file: SourceFile, options: CompilerOptions) => void { } // We create a return control flow graph for IIFEs and constructors. For constructors // we use the return control flow graph in strict property initialization checks. - currentReturnTarget = isImmediatelyInvoked || node.kind === SyntaxKind.Constructor || (isInJSFile(node) && (node.kind === SyntaxKind.FunctionDeclaration || node.kind === SyntaxKind.FunctionExpression)) ? createBranchLabel() : undefined; + currentReturnTarget = isImmediatelyInvoked || isLambdaArgument || node.kind === SyntaxKind.Constructor || (isInJSFile(node) && (node.kind === SyntaxKind.FunctionDeclaration || node.kind === SyntaxKind.FunctionExpression)) ? createBranchLabel() : undefined; currentExceptionTarget = undefined; currentBreakTarget = undefined; currentContinueTarget = undefined; @@ -1048,7 +1051,7 @@ function createBinder(): (file: SourceFile, options: CompilerOptions) => void { if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); currentFlow = finishFlowLabel(currentReturnTarget); - if (node.kind === SyntaxKind.Constructor || node.kind === SyntaxKind.ClassStaticBlockDeclaration || (isInJSFile(node) && (node.kind === SyntaxKind.FunctionDeclaration || node.kind === SyntaxKind.FunctionExpression))) { + if (isLambdaArgument && hasFlowMutation || node.kind === SyntaxKind.Constructor || node.kind === SyntaxKind.ClassStaticBlockDeclaration || (isInJSFile(node) && (node.kind === SyntaxKind.FunctionDeclaration || node.kind === SyntaxKind.FunctionExpression))) { (node as FunctionLikeDeclaration | ClassStaticBlockDeclaration).returnFlowNode = currentFlow; } } @@ -1391,6 +1394,7 @@ function createBinder(): (file: SourceFile, options: CompilerOptions) => void { function createFlowMutation(flags: FlowFlags.Assignment | FlowFlags.ArrayMutation, antecedent: FlowNode, node: Expression | VariableDeclaration | ArrayBindingElement) { setFlowNodeReferenced(antecedent); hasFlowEffects = true; + if (node.kind !== SyntaxKind.VariableDeclaration && node.kind !== SyntaxKind.BindingElement) hasFlowMutation = true; const result = createFlowNode(flags, node, antecedent) as FlowAssignment | FlowArrayMutation; if (currentExceptionTarget) { addAntecedent(currentExceptionTarget, result); @@ -1404,6 +1408,11 @@ function createBinder(): (file: SourceFile, options: CompilerOptions) => void { return createFlowNode(FlowFlags.Call, node, antecedent) as FlowCall; } + function createFlowLambdaArgs(antecedent: FlowNode, node: CallExpression) { + setFlowNodeReferenced(antecedent); + return createFlowNode(FlowFlags.LambdaArgs, node, antecedent) as FlowCall; + } + function finishFlowLabel(flow: FlowLabel): FlowNode { const antecedents = flow.antecedent; if (!antecedents) { @@ -2209,10 +2218,22 @@ function createBinder(): (file: SourceFile, options: CompilerOptions) => void { bind(node.expression); } else { - bindEachChild(node); + bind(node.expression); + bindEach(node.typeArguments); + let hasLambdaArgs = false; + for (const arg of node.arguments) { + const saveHasFlowMutation = hasFlowMutation; + hasFlowMutation = false; + bind(arg); + hasLambdaArgs ||= !!getLambdaArgument(arg) && hasFlowMutation; + hasFlowMutation ||= saveHasFlowMutation; + } if (node.expression.kind === SyntaxKind.SuperKeyword) { currentFlow = createFlowCall(currentFlow, node); } + if (hasLambdaArgs) { + currentFlow = createFlowLambdaArgs(currentFlow, node); + } } } if (node.expression.kind === SyntaxKind.PropertyAccessExpression) { diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 06346c66ba0ac..ace096e86da70 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -329,6 +329,7 @@ import { getJSXImplicitImportBase, getJSXRuntimeImport, getJSXTransformEnabled, + getLambdaArgument, getLeftmostAccessExpression, getLineAndCharacterOfPosition, getMembersOfDeclaration, @@ -2285,6 +2286,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { var flowLoopStart = 0; var flowLoopCount = 0; var sharedFlowCount = 0; + var mutationFlowCount = 0; var flowAnalysisDisabled = false; var flowInvocationCount = 0; var lastFlowNode: FlowNode | undefined; @@ -2322,6 +2324,8 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { var flowLoopTypes: Type[][] = []; var sharedFlowNodes: FlowNode[] = []; var sharedFlowTypes: FlowType[] = []; + var mutationFlowNodes: FlowNode[] = []; + var mutationFlowStates: boolean[] = []; var flowNodeReachable: (boolean | undefined)[] = []; var flowNodePostSuper: (boolean | undefined)[] = []; var potentialThisCollisions: Node[] = []; @@ -21374,8 +21378,9 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { let related = callbacks ? compareSignaturesRelated(targetSig, sourceSig, (checkMode & SignatureCheckMode.StrictArity) | (strictVariance ? SignatureCheckMode.StrictCallback : SignatureCheckMode.BivariantCallback), reportErrors, errorReporter, incompatibleErrorReporter, compareTypes, reportUnreliableMarkers) : !(checkMode & SignatureCheckMode.Callback) && !strictVariance && compareTypes(sourceType, targetType, /*reportErrors*/ false) || compareTypes(targetType, sourceType, reportErrors); - // With strict arity, (x: number | undefined) => void is a subtype of (x?: number | undefined) => void - if (related && checkMode & SignatureCheckMode.StrictArity && i >= getMinArgumentCount(source) && i < getMinArgumentCount(target) && compareTypes(sourceType, targetType, /*reportErrors*/ false)) { + // With strict arity, (x: number | undefined) => void is a subtype of (x?: number | undefined) => void, + // and (x: () => void) => void is a subtype of (immediate x: () => void) => void. + if (related && checkMode & SignatureCheckMode.StrictArity && (i >= getMinArgumentCount(source) && i < getMinArgumentCount(target) || isImmediateParameterPosition(source, i) && !isImmediateParameterPosition(target, i)) && compareTypes(sourceType, targetType, /*reportErrors*/ false)) { related = Ternary.False; } if (!related) { @@ -28162,8 +28167,8 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } noCacheCheck = false; } - if (flags & (FlowFlags.Assignment | FlowFlags.Condition | FlowFlags.ArrayMutation)) { - flow = (flow as FlowAssignment | FlowCondition | FlowArrayMutation).antecedent; + if (flags & (FlowFlags.Assignment | FlowFlags.Condition | FlowFlags.ArrayMutation | FlowFlags.LambdaArgs)) { + flow = (flow as FlowAssignment | FlowCondition | FlowArrayMutation | FlowCall).antecedent; } else if (flags & FlowFlags.Call) { const signature = getEffectsSignature((flow as FlowCall).node); @@ -28231,8 +28236,8 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } noCacheCheck = false; } - if (flags & (FlowFlags.Assignment | FlowFlags.Condition | FlowFlags.ArrayMutation | FlowFlags.SwitchClause)) { - flow = (flow as FlowAssignment | FlowCondition | FlowArrayMutation | FlowSwitchClause).antecedent; + if (flags & (FlowFlags.Assignment | FlowFlags.Condition | FlowFlags.ArrayMutation | FlowFlags.SwitchClause | FlowFlags.LambdaArgs)) { + flow = (flow as FlowAssignment | FlowCondition | FlowArrayMutation | FlowSwitchClause | FlowCall).antecedent; } else if (flags & FlowFlags.Call) { if ((flow as FlowCall).node.expression.kind === SyntaxKind.SuperKeyword) { @@ -28292,6 +28297,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { function getFlowTypeOfReference(reference: Node, declaredType: Type, initialType = declaredType, flowContainer?: Node, flowNode = tryCast(reference, canHaveFlowNode)?.flowNode) { let key: string | undefined; let isKeySet = false; + let inLambdaArg = false; let flowDepth = 0; if (flowAnalysisDisabled) { return errorType; @@ -28301,8 +28307,10 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } flowInvocationCount++; const sharedFlowStart = sharedFlowCount; + const mutationFlowStart = mutationFlowCount; const evolvedType = getTypeFromFlowType(getTypeAtFlowNode(flowNode)); sharedFlowCount = sharedFlowStart; + mutationFlowCount = mutationFlowStart; // When the reference is 'x' in an 'x.length', 'x.push(value)', 'x.unshift(value)' or x[n] = value' operation, // we give type 'any[]' to 'x' instead of using the type determined by control flow analysis such that operations // on empty arrays are possible without implicit any errors and new element types can be inferred without @@ -28383,6 +28391,9 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { continue; } } + else if (flags & FlowFlags.LambdaArgs) { + type = getTypeAtFlowLambdaArgs(flow as FlowCall); + } else if (flags & FlowFlags.ReduceLabel) { const target = (flow as FlowReduceLabel).node.target; const saveAntecedents = target.antecedent; @@ -28394,7 +28405,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { // Check if we should continue with the control flow of the containing function. const container = (flow as FlowStart).node; if ( - container && container !== flowContainer && + container && container !== flowContainer && !inLambdaArg && reference.kind !== SyntaxKind.PropertyAccessExpression && reference.kind !== SyntaxKind.ElementAccessExpression && !(reference.kind === SyntaxKind.ThisKeyword && container.kind !== SyntaxKind.ArrowFunction) @@ -28408,7 +28419,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { else { // Unreachable code errors are reported in the binding phase. Here we // simply return the non-auto declared type to reduce follow-on errors. - type = convertAutoToAny(declaredType); + type = inLambdaArg ? initialType : convertAutoToAny(declaredType); } if (sharedFlow) { // Record visited node and the associated type in the cache. @@ -28521,6 +28532,118 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { return undefined; } + function getTypeAtFlowLambdaArgs(flow: FlowCall): FlowType { + const flowType = getTypeAtFlowNode(flow.antecedent); + const saveInitialType = initialType; + initialType = getTypeFromFlowType(flowType); + let lambdaTypes: Type[] | undefined; + // We assume that lambda arguments in 'immediate' parameter positions may or may not have executed. Thus, + // lambda arguments can only have a widening effect and will have no effect if we already have the declared + // type (the widest possible type). + if (initialType !== declaredType) { + const saveInLambdaArg = inLambdaArg; + inLambdaArg = true; + const args = flow.node.arguments; + let signatures: readonly Signature[] | undefined; + for (let i = 0; i < args.length; i++) { + const lambda = getLambdaArgument(args[i]); + // We use isMutationFlowNode to quickly check whether the reference is mutated anywhere in the lambda. + // This check doesn't require resolving any types, thus eliminating circularities that would otherwise + // occur for no good reason. + if (lambda && lambda.returnFlowNode && isMutationFlowNode(lambda.returnFlowNode, /*noCacheCheck*/ false)) { + // Only when we know that the reference is actually mutated in the lambda do we resolve types and + // signatures. Note that we don't perform type inference and overload resolution, again to reduce + // circularities. Instead, we simply check if any signature has a deferred callback marker in the + // particular argument position. + signatures ??= getSignaturesOfType(getTypeOfExpression(flow.node.expression), SignatureKind.Call); + if (some(signatures, sig => isImmediateParameterPosition(sig, i))) { + const lambdaType = getTypeFromFlowType(getTypeAtFlowNode(lambda.returnFlowNode)); + if (lambdaType !== initialType) { + lambdaTypes ??= [initialType]; + lambdaTypes.push(lambdaType); + } + } + } + } + inLambdaArg = saveInLambdaArg; + } + initialType = saveInitialType; + return lambdaTypes ? createFlowType(getUnionOrEvolvingArrayType(lambdaTypes, UnionReduction.Literal), isIncomplete(flowType)) : flowType; + } + + function isMutationFlowNode(flow: FlowNode, noCacheCheck: boolean): boolean { + while (true) { + const flags = flow.flags; + if (flags & FlowFlags.Shared) { + if (!noCacheCheck) { + let cached = getMutationStateForFlowNode(flow); + if (cached === undefined) { + setMutationStateForFlowNode(flow, cached = isMutationFlowNode(flow, /*noCacheCheck*/ true)); + } + return cached; + } + noCacheCheck = false; + } + if (flags & FlowFlags.Assignment) { + if (isOrContainsMatchingReference(reference, (flow as FlowAssignment).node)) { + return true; + } + } + else if (flags & FlowFlags.BranchLabel) { + return some((flow as FlowLabel).antecedent, f => isMutationFlowNode(f, /*noCacheCheck*/ false)); + } + else if (flags & FlowFlags.LoopLabel) { + let cached = getMutationStateForFlowNode(flow); + if (cached === undefined) { + const index = setMutationStateForFlowNode(flow, false); + cached = mutationFlowStates[index] = some((flow as FlowLabel).antecedent, f => isMutationFlowNode(f, /*noCacheCheck*/ false)); + } + return cached; + } + else if (flags & FlowFlags.ArrayMutation) { + if (declaredType === autoType || declaredType === autoArrayType) { + const node = (flow as FlowArrayMutation).node; + const expr = node.kind === SyntaxKind.CallExpression ? + (node.expression as PropertyAccessExpression).expression : + (node.left as ElementAccessExpression).expression; + if (isMatchingReference(reference, getReferenceCandidate(expr))) { + return true; + } + } + } + else if (flags & FlowFlags.LambdaArgs) { + const mutation = some((flow as FlowCall).node.arguments, arg => { + const lambda = getLambdaArgument(arg); + return !!(lambda && lambda.returnFlowNode && isMutationFlowNode(lambda.returnFlowNode, /*noCacheCheck*/ false)); + }); + if (mutation) { + return true; + } + } + else if (!(flags & (FlowFlags.Call | FlowFlags.Condition | FlowFlags.SwitchClause | FlowFlags.ReduceLabel))) { + return false; + } + flow = (flow as FlowAssignment | FlowArrayMutation | FlowCall | FlowCondition | FlowSwitchClause | FlowReduceLabel).antecedent; + } + } + + function getMutationStateForFlowNode(flow: FlowNode) { + for (let i = mutationFlowStart; i < mutationFlowCount; i++) { + if (mutationFlowNodes[i] === flow) { + return mutationFlowStates[i]; + } + } + return undefined; + } + + function setMutationStateForFlowNode(flow: FlowNode, state: boolean) { + const index = mutationFlowCount; + mutationFlowNodes[index] = flow; + mutationFlowStates[index] = state; + mutationFlowCount++; + return index; + } + function getTypeAtFlowArrayMutation(flow: FlowArrayMutation): FlowType | undefined { if (declaredType === autoType || declaredType === autoArrayType) { const node = flow.node; @@ -37582,6 +37705,13 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { return elementType && isTypeAny(elementType) ? anyType : restType; } + function isImmediateParameterPosition(signature: Signature, pos: number) { + return someSignature(signature, s => { + const index = pos < s.parameters.length ? pos : signatureHasRestParameter(s) ? s.parameters.length - 1 : -1; + return index >= 0 && !!(getDeclarationModifierFlagsFromSymbol(s.parameters[index]) & (ModifierFlags.Immediate | ModifierFlags.JSDocImmediate)); + }); + } + // Return the number of parameters in a signature. The rest parameter, if present, counts as one // parameter. For example, the parameter count of (x: number, y: number, ...z: string[]) is 3 and // the parameter count of (x: number, ...args: [number, ...string[], boolean])) is also 3. In the @@ -41014,6 +41144,12 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { if (node.dotDotDotToken && !isBindingPattern(node.name) && !isTypeAssignableTo(getReducedType(getTypeOfSymbol(node.symbol)), anyReadonlyArrayType)) { error(node, Diagnostics.A_rest_parameter_must_be_of_an_array_type); } + if (hasEffectiveModifier(node, ModifierFlags.Immediate | ModifierFlags.JSDocImmediate)) { + const funcType = node.dotDotDotToken ? createArrayType(globalFunctionType, /*readonly*/ true) : globalFunctionType; + if (!areTypesComparable(getTypeOfSymbol(node.symbol), funcType)) { + error(node, Diagnostics.An_immediate_parameter_must_have_a_type_that_permits_functions); + } + } } function checkTypePredicate(node: TypePredicateNode): void { @@ -50892,6 +51028,28 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { flags |= inOutFlag; break; } + + case SyntaxKind.ImmediateKeyword: + if (node.kind !== SyntaxKind.Parameter) { + return grammarErrorOnNode(modifier, Diagnostics.immediate_modifier_can_only_appear_on_a_parameter_declaration); + } + if (flags & ModifierFlags.Immediate) { + return grammarErrorOnNode(modifier, Diagnostics._0_modifier_already_seen, "immediate"); + } + if (flags & ModifierFlags.Public) { + return grammarErrorOnNode(modifier, Diagnostics._0_modifier_must_precede_1_modifier, "immediate", "public"); + } + if (flags & ModifierFlags.Protected) { + return grammarErrorOnNode(modifier, Diagnostics._0_modifier_must_precede_1_modifier, "immediate", "protected"); + } + if (flags & ModifierFlags.Private) { + return grammarErrorOnNode(modifier, Diagnostics._0_modifier_must_precede_1_modifier, "immediate", "private"); + } + if (flags & ModifierFlags.Readonly) { + return grammarErrorOnNode(modifier, Diagnostics._0_modifier_must_precede_1_modifier, "immediate", "readonly"); + } + flags |= ModifierFlags.Immediate; + break; } } } diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 850d5ca1022af..1da5558b1880c 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -971,6 +971,10 @@ "category": "Error", "code": 1293 }, + "'immediate' modifier can only appear on a parameter declaration.": { + "category": "Error", + "code": 1294 + }, "'with' statements are not allowed in an async function block.": { "category": "Error", @@ -3940,6 +3944,11 @@ "category": "Error", "code": 2873 }, + "An 'immediate' parameter must have a type that permits functions.": { + "category": "Error", + "code": 2874 + }, + "Import declaration '{0}' is using private name '{1}'.": { "category": "Error", "code": 4000 diff --git a/src/compiler/factory/nodeFactory.ts b/src/compiler/factory/nodeFactory.ts index 8f3b15690f7e2..883036dc1e372 100644 --- a/src/compiler/factory/nodeFactory.ts +++ b/src/compiler/factory/nodeFactory.ts @@ -225,6 +225,7 @@ import { JSDocDeprecatedTag, JSDocEnumTag, JSDocFunctionType, + JSDocImmediateTag, JSDocImplementsTag, JSDocImportTag, JSDocLink, @@ -938,6 +939,12 @@ export function createNodeFactory(flags: NodeFactoryFlags, baseFactory: BaseNode get updateJSDocDeprecatedTag() { return getJSDocSimpleTagUpdateFunction(SyntaxKind.JSDocDeprecatedTag); }, + get createJSDocImmediateTag() { + return getJSDocSimpleTagCreateFunction(SyntaxKind.JSDocImmediateTag); + }, + get updateJSDocImmediateTag() { + return getJSDocSimpleTagUpdateFunction(SyntaxKind.JSDocImmediateTag); + }, get createJSDocThrowsTag() { return getJSDocTypeLikeTagCreateFunction(SyntaxKind.JSDocThrowsTag); }, @@ -1471,6 +1478,7 @@ export function createNodeFactory(flags: NodeFactoryFlags, baseFactory: BaseNode case SyntaxKind.ReadonlyKeyword: case SyntaxKind.AbstractKeyword: case SyntaxKind.DeclareKeyword: + case SyntaxKind.ImmediateKeyword: case SyntaxKind.ConstKeyword: case SyntaxKind.AnyKeyword: case SyntaxKind.NumberKeyword: @@ -1555,6 +1563,7 @@ export function createNodeFactory(flags: NodeFactoryFlags, baseFactory: BaseNode if (flags & ModifierFlags.Ambient) result.push(createModifier(SyntaxKind.DeclareKeyword)); if (flags & ModifierFlags.Default) result.push(createModifier(SyntaxKind.DefaultKeyword)); if (flags & ModifierFlags.Const) result.push(createModifier(SyntaxKind.ConstKeyword)); + if (flags & ModifierFlags.Immediate) result.push(createModifier(SyntaxKind.ImmediateKeyword)); if (flags & ModifierFlags.Public) result.push(createModifier(SyntaxKind.PublicKeyword)); if (flags & ModifierFlags.Private) result.push(createModifier(SyntaxKind.PrivateKeyword)); if (flags & ModifierFlags.Protected) result.push(createModifier(SyntaxKind.ProtectedKeyword)); diff --git a/src/compiler/factory/nodeTests.ts b/src/compiler/factory/nodeTests.ts index 8aa4bb02e83d2..654c6bbc5daf3 100644 --- a/src/compiler/factory/nodeTests.ts +++ b/src/compiler/factory/nodeTests.ts @@ -90,6 +90,7 @@ import { JSDocDeprecatedTag, JSDocEnumTag, JSDocFunctionType, + JSDocImmediateTag, JSDocImplementsTag, JSDocImportTag, JSDocLink, @@ -1137,6 +1138,10 @@ export function isJSDocDeprecatedTag(node: Node): node is JSDocDeprecatedTag { return node.kind === SyntaxKind.JSDocDeprecatedTag; } +export function isJSDocImmediateTag(node: Node): node is JSDocImmediateTag { + return node.kind === SyntaxKind.JSDocImmediateTag; +} + export function isJSDocSeeTag(node: Node): node is JSDocSeeTag { return node.kind === SyntaxKind.JSDocSeeTag; } diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index b20d4b8b8b52e..d9fa26d3b4520 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -4847,6 +4847,7 @@ namespace Parser { // Skip modifiers parseModifiers(/*allowDecorators*/ false); } + parseOptional(SyntaxKind.DotDotDotToken); if (isIdentifier() || token() === SyntaxKind.ThisKeyword) { nextToken(); return true; @@ -9080,6 +9081,9 @@ namespace Parser { hasDeprecatedTag = true; tag = parseSimpleTag(start, factory.createJSDocDeprecatedTag, tagName, margin, indentText); break; + case "immediate": + tag = parseSimpleTag(start, factory.createJSDocImmediateTag, tagName, margin, indentText); + break; case "this": tag = parseThisTag(start, tagName, margin, indentText); break; diff --git a/src/compiler/program.ts b/src/compiler/program.ts index bd9b42caae953..878f88e481d0a 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -3342,6 +3342,7 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg case SyntaxKind.ProtectedKeyword: case SyntaxKind.ReadonlyKeyword: case SyntaxKind.DeclareKeyword: + case SyntaxKind.ImmediateKeyword: case SyntaxKind.AbstractKeyword: case SyntaxKind.OverrideKeyword: case SyntaxKind.InKeyword: diff --git a/src/compiler/scanner.ts b/src/compiler/scanner.ts index ce01171fcaafe..1800e8dcb9b31 100644 --- a/src/compiler/scanner.ts +++ b/src/compiler/scanner.ts @@ -163,6 +163,7 @@ export const textToKeywordObj: MapLike = { function: SyntaxKind.FunctionKeyword, get: SyntaxKind.GetKeyword, if: SyntaxKind.IfKeyword, + immediate: SyntaxKind.ImmediateKeyword, implements: SyntaxKind.ImplementsKeyword, import: SyntaxKind.ImportKeyword, in: SyntaxKind.InKeyword, @@ -351,7 +352,7 @@ const commentDirectiveRegExSingleLine = /^\/\/\/?\s*@(ts-expect-error|ts-ignore) */ const commentDirectiveRegExMultiLine = /^(?:\/|\*)*\s*@(ts-expect-error|ts-ignore)/; -const jsDocSeeOrLink = /@(?:see|link)/i; +const jsDocSeeOrLinkOrImmediate = /@(?:see|link|immediate)/i; function lookupInUnicodeMap(code: number, map: readonly number[]): boolean { // Bail out quickly if it couldn't possibly be in the map. @@ -2396,7 +2397,7 @@ export function createScanner(languageVersion: ScriptTarget, skipTrivia: boolean return false; } - return jsDocSeeOrLink.test(text.slice(fullStartPos, pos)); + return jsDocSeeOrLinkOrImmediate.test(text.slice(fullStartPos, pos)); } function reScanInvalidIdentifier(): SyntaxKind { diff --git a/src/compiler/transformers/ts.ts b/src/compiler/transformers/ts.ts index d2b3e1121f406..5ab6ea370c0de 100644 --- a/src/compiler/transformers/ts.ts +++ b/src/compiler/transformers/ts.ts @@ -661,6 +661,7 @@ export function transformTypeScript(context: TransformationContext) { case SyntaxKind.OverrideKeyword: case SyntaxKind.ConstKeyword: case SyntaxKind.DeclareKeyword: + case SyntaxKind.ImmediateKeyword: case SyntaxKind.ReadonlyKeyword: case SyntaxKind.InKeyword: case SyntaxKind.OutKeyword: diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 9b0ab54b0aa0e..f710a4af1cff1 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -196,6 +196,7 @@ export const enum SyntaxKind { ConstructorKeyword, DeclareKeyword, GetKeyword, + ImmediateKeyword, InferKeyword, IntrinsicKeyword, IsKeyword, @@ -419,6 +420,7 @@ export const enum SyntaxKind { JSDocImplementsTag, JSDocAuthorTag, JSDocDeprecatedTag, + JSDocImmediateTag, JSDocClassTag, JSDocPublicTag, JSDocPrivateTag, @@ -611,6 +613,7 @@ export type KeywordSyntaxKind = | SyntaxKind.GetKeyword | SyntaxKind.GlobalKeyword | SyntaxKind.IfKeyword + | SyntaxKind.ImmediateKeyword | SyntaxKind.ImplementsKeyword | SyntaxKind.ImportKeyword | SyntaxKind.InferKeyword @@ -669,6 +672,7 @@ export type ModifierSyntaxKind = | SyntaxKind.DeclareKeyword | SyntaxKind.DefaultKeyword | SyntaxKind.ExportKeyword + | SyntaxKind.ImmediateKeyword | SyntaxKind.InKeyword | SyntaxKind.PrivateKeyword | SyntaxKind.ProtectedKeyword @@ -865,9 +869,11 @@ export const enum ModifierFlags { In = 1 << 13, // Contravariance modifier Out = 1 << 14, // Covariance modifier Decorator = 1 << 15, // Contains a decorator. + Immediate = 1 << 16, // Parameter // JSDoc-only modifiers - Deprecated = 1 << 16, // Deprecated tag. + Deprecated = 1 << 17, // Deprecated tag. + JSDocImmediate = 1 << 18, // Parameter // Cache-only JSDoc-modifiers. Should match order of Syntactic/JSDoc modifiers, above. /** @internal */ JSDocPublic = 1 << 23, // if this value changes, `selectEffectiveModifierFlags` must change accordingly @@ -875,12 +881,12 @@ export const enum ModifierFlags { /** @internal */ JSDocProtected = 1 << 25, /** @internal */ JSDocReadonly = 1 << 26, /** @internal */ JSDocOverride = 1 << 27, - + /** @internal */ SyntacticOrJSDocModifiers = Public | Private | Protected | Readonly | Override, - /** @internal */ SyntacticOnlyModifiers = Export | Ambient | Abstract | Static | Accessor | Async | Default | Const | In | Out | Decorator, + /** @internal */ SyntacticOnlyModifiers = Export | Ambient | Abstract | Static | Accessor | Async | Default | Const | In | Out | Decorator | Immediate, /** @internal */ SyntacticModifiers = SyntacticOrJSDocModifiers | SyntacticOnlyModifiers, /** @internal */ JSDocCacheOnlyModifiers = JSDocPublic | JSDocPrivate | JSDocProtected | JSDocReadonly | JSDocOverride, - /** @internal */ JSDocOnlyModifiers = Deprecated, + /** @internal */ JSDocOnlyModifiers = Deprecated | JSDocImmediate, /** @internal */ NonCacheOnlyModifiers = SyntacticOrJSDocModifiers | SyntacticOnlyModifiers | JSDocOnlyModifiers, HasComputedJSDocModifiers = 1 << 28, // Indicates the computed modifier flags include modifiers from JSDoc. @@ -891,9 +897,9 @@ export const enum ModifierFlags { ParameterPropertyModifier = AccessibilityModifier | Readonly | Override, NonPublicAccessibilityModifier = Private | Protected, - TypeScriptModifier = Ambient | Public | Private | Protected | Readonly | Abstract | Const | Override | In | Out, + TypeScriptModifier = Ambient | Public | Private | Protected | Readonly | Abstract | Const | Override | In | Out | Immediate, ExportDefault = Export | Default, - All = Export | Ambient | Public | Private | Protected | Static | Readonly | Abstract | Accessor | Async | Default | Const | Deprecated | Override | In | Out | Decorator, + All = Export | Ambient | Public | Private | Protected | Static | Readonly | Abstract | Accessor | Async | Default | Const | Deprecated | Override | In | Out | Immediate | Decorator, Modifier = All & ~Decorator, } @@ -1631,6 +1637,7 @@ export type ConstKeyword = ModifierToken; export type DeclareKeyword = ModifierToken; export type DefaultKeyword = ModifierToken; export type ExportKeyword = ModifierToken; +export type ImmediateKeyword = ModifierToken; export type InKeyword = ModifierToken; export type PrivateKeyword = ModifierToken; export type ProtectedKeyword = ModifierToken; @@ -1648,6 +1655,7 @@ export type Modifier = | DeclareKeyword | DefaultKeyword | ExportKeyword + | ImmediateKeyword | InKeyword | PrivateKeyword | ProtectedKeyword @@ -3986,6 +3994,10 @@ export interface JSDocDeprecatedTag extends JSDocTag { kind: SyntaxKind.JSDocDeprecatedTag; } +export interface JSDocImmediateTag extends JSDocTag { + kind: SyntaxKind.JSDocImmediateTag; +} + export interface JSDocClassTag extends JSDocTag { readonly kind: SyntaxKind.JSDocClassTag; } @@ -4133,8 +4145,9 @@ export const enum FlowFlags { ArrayMutation = 1 << 8, // Potential array mutation Call = 1 << 9, // Potential assertion call ReduceLabel = 1 << 10, // Temporarily reduce antecedents of label - Referenced = 1 << 11, // Referenced as antecedent once - Shared = 1 << 12, // Referenced as antecedent more than once + LambdaArgs = 1 << 11, // Call expression with lambda arguments + Referenced = 1 << 12, // Referenced as antecedent once + Shared = 1 << 13, // Referenced as antecedent more than once Label = BranchLabel | LoopLabel, Condition = TrueCondition | FalseCondition, @@ -6443,7 +6456,6 @@ export const enum ObjectFlags { ContainsSpread = 1 << 21, // Object literal contains spread operation ObjectRestType = 1 << 22, // Originates in object rest declaration InstantiationExpressionType = 1 << 23, // Originates in instantiation expression - SingleSignatureType = 1 << 27, // A single signature type extracted from a potentially broader type /** @internal */ IsClassInstanceClone = 1 << 24, // Type is a clone of a class instance type // Flags that require TypeFlags.Object and ObjectFlags.Reference @@ -6451,6 +6463,7 @@ export const enum ObjectFlags { IdenticalBaseTypeCalculated = 1 << 25, // has had `getSingleBaseForNonAugmentingSubtype` invoked on it already /** @internal */ IdenticalBaseTypeExists = 1 << 26, // has a defined cachedEquivalentBaseType member + SingleSignatureType = 1 << 27, // A single signature type extracted from a potentially broader type // Flags that require TypeFlags.UnionOrIntersection or TypeFlags.Substitution /** @internal */ @@ -9044,6 +9057,8 @@ export interface NodeFactory { updateJSDocUnknownTag(node: JSDocUnknownTag, tagName: Identifier, comment: string | NodeArray | undefined): JSDocUnknownTag; createJSDocDeprecatedTag(tagName: Identifier | undefined, comment?: string | NodeArray): JSDocDeprecatedTag; updateJSDocDeprecatedTag(node: JSDocDeprecatedTag, tagName: Identifier | undefined, comment?: string | NodeArray): JSDocDeprecatedTag; + createJSDocImmediateTag(tagName: Identifier | undefined, comment?: string | NodeArray): JSDocImmediateTag; + updateJSDocImmediateTag(node: JSDocImmediateTag, tagName: Identifier | undefined, comment?: string | NodeArray): JSDocImmediateTag; createJSDocOverrideTag(tagName: Identifier | undefined, comment?: string | NodeArray): JSDocOverrideTag; updateJSDocOverrideTag(node: JSDocOverrideTag, tagName: Identifier | undefined, comment?: string | NodeArray): JSDocOverrideTag; createJSDocThrowsTag(tagName: Identifier, typeExpression: JSDocTypeExpression | undefined, comment?: string | NodeArray): JSDocThrowsTag; diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index b7600682b6ca2..7f3676f6e5960 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -170,6 +170,7 @@ import { getImpliedNodeFormatForEmitWorker, getJSDocAugmentsTag, getJSDocDeprecatedTagNoCache, + getJSDocImmediateTagNoCache, getJSDocImplementsTags, getJSDocOverrideTagNoCache, getJSDocParameterTags, @@ -7057,7 +7058,7 @@ function getModifierFlagsWorker(node: Node, includeJSDoc: boolean, alwaysInclude node.modifierFlagsCache = getSyntacticModifierFlagsNoCache(node) | ModifierFlags.HasComputedFlags; } - if (alwaysIncludeJSDoc || includeJSDoc && isInJSFile(node)) { + if (alwaysIncludeJSDoc || includeJSDoc && (isInJSFile(node) || isParameter(node) && node.jsDoc)) { if (!(node.modifierFlagsCache & ModifierFlags.HasComputedJSDocModifiers) && node.parent) { node.modifierFlagsCache |= getRawJSDocModifierFlagsNoCache(node) | ModifierFlags.HasComputedJSDocModifiers; } @@ -7096,15 +7097,18 @@ export function getSyntacticModifierFlags(node: Node): ModifierFlags { function getRawJSDocModifierFlagsNoCache(node: Node): ModifierFlags { let flags = ModifierFlags.None; - if (!!node.parent && !isParameter(node)) { + if (node.parent) { if (isInJSFile(node)) { - if (getJSDocPublicTagNoCache(node)) flags |= ModifierFlags.JSDocPublic; - if (getJSDocPrivateTagNoCache(node)) flags |= ModifierFlags.JSDocPrivate; - if (getJSDocProtectedTagNoCache(node)) flags |= ModifierFlags.JSDocProtected; - if (getJSDocReadonlyTagNoCache(node)) flags |= ModifierFlags.JSDocReadonly; - if (getJSDocOverrideTagNoCache(node)) flags |= ModifierFlags.JSDocOverride; + if (!isParameter(node)) { + if (getJSDocPublicTagNoCache(node)) flags |= ModifierFlags.JSDocPublic; + if (getJSDocPrivateTagNoCache(node)) flags |= ModifierFlags.JSDocPrivate; + if (getJSDocProtectedTagNoCache(node)) flags |= ModifierFlags.JSDocProtected; + if (getJSDocReadonlyTagNoCache(node)) flags |= ModifierFlags.JSDocReadonly; + if (getJSDocOverrideTagNoCache(node)) flags |= ModifierFlags.JSDocOverride; + } } - if (getJSDocDeprecatedTagNoCache(node)) flags |= ModifierFlags.Deprecated; + if (!isParameter(node) && getJSDocDeprecatedTagNoCache(node)) flags |= ModifierFlags.Deprecated; + if (getJSDocImmediateTagNoCache(node)) flags |= ModifierFlags.JSDocImmediate; } return flags; @@ -7194,6 +7198,8 @@ export function modifierToFlag(token: SyntaxKind): ModifierFlags { return ModifierFlags.In; case SyntaxKind.OutKeyword: return ModifierFlags.Out; + case SyntaxKind.ImmediateKeyword: + return ModifierFlags.Immediate; case SyntaxKind.Decorator: return ModifierFlags.Decorator; } @@ -11784,3 +11790,15 @@ export function isSideEffectImport(node: Node): boolean { const ancestor = findAncestor(node, isImportDeclaration); return !!ancestor && !ancestor.importClause; } + +/** @internal */ +export function getLambdaArgument(node: Node): FunctionLikeDeclaration | undefined { + switch (node.kind) { + case SyntaxKind.FunctionExpression: + case SyntaxKind.ArrowFunction: + return !hasSyntacticModifier(node, ModifierFlags.Async) && !(node as FunctionLikeDeclaration).asteriskToken ? node as FunctionLikeDeclaration : undefined; + case SyntaxKind.ParenthesizedExpression: + return getLambdaArgument((node as ParenthesizedExpression).expression); + } + return undefined; +} diff --git a/src/compiler/utilitiesPublic.ts b/src/compiler/utilitiesPublic.ts index dfc3f2d069bde..c441d03d641ac 100644 --- a/src/compiler/utilitiesPublic.ts +++ b/src/compiler/utilitiesPublic.ts @@ -140,6 +140,7 @@ import { isJSDocDeprecatedTag, isJSDocEnumTag, isJSDocFunctionType, + isJSDocImmediateTag, isJSDocImplementsTag, isJSDocOverloadTag, isJSDocOverrideTag, @@ -183,6 +184,7 @@ import { JSDocContainer, JSDocDeprecatedTag, JSDocEnumTag, + JSDocImmediateTag, JSDocImplementsTag, JSDocLink, JSDocLinkCode, @@ -1161,6 +1163,16 @@ export function getJSDocDeprecatedTagNoCache(node: Node): JSDocDeprecatedTag | u return getFirstJSDocTag(node, isJSDocDeprecatedTag, /*noCache*/ true); } +/** Gets the JSDoc immediate tag for the node if present */ +export function getJSDocImmediateTag(node: Node): JSDocImmediateTag | undefined { + return getFirstJSDocTag(node, isJSDocImmediateTag); +} + +/** @internal */ +export function getJSDocImmediateTagNoCache(node: Node): JSDocImmediateTag | undefined { + return getFirstJSDocTag(node, isJSDocImmediateTag, /*noCache*/ true); +} + /** Gets the JSDoc enum tag for the node if present */ export function getJSDocEnumTag(node: Node): JSDocEnumTag | undefined { return getFirstJSDocTag(node, isJSDocEnumTag); @@ -1598,6 +1610,7 @@ export function isModifierKind(token: SyntaxKind): token is Modifier["kind"] { case SyntaxKind.DeclareKeyword: case SyntaxKind.DefaultKeyword: case SyntaxKind.ExportKeyword: + case SyntaxKind.ImmediateKeyword: case SyntaxKind.InKeyword: case SyntaxKind.PublicKeyword: case SyntaxKind.PrivateKeyword: diff --git a/src/lib/es2015.collection.d.ts b/src/lib/es2015.collection.d.ts index e88f0d4c3b405..86c2f0c27bb29 100644 --- a/src/lib/es2015.collection.d.ts +++ b/src/lib/es2015.collection.d.ts @@ -7,7 +7,7 @@ interface Map { /** * Executes a provided function once per each key/value pair in the Map, in insertion order. */ - forEach(callbackfn: (value: V, key: K, map: Map) => void, thisArg?: any): void; + forEach(/** @immediate */ callbackfn: (value: V, key: K, map: Map) => void, thisArg?: any): void; /** * Returns a specified element from the Map object. If the value that is associated to the provided key is an object, then you will get a reference to that object and any change made to that object will effectively modify it inside the Map. * @returns Returns the element associated with the specified key. If no element is associated with the specified key, undefined is returned. @@ -35,7 +35,7 @@ interface MapConstructor { declare var Map: MapConstructor; interface ReadonlyMap { - forEach(callbackfn: (value: V, key: K, map: ReadonlyMap) => void, thisArg?: any): void; + forEach(/** @immediate */ callbackfn: (value: V, key: K, map: ReadonlyMap) => void, thisArg?: any): void; get(key: K): V | undefined; has(key: K): boolean; readonly size: number; @@ -83,7 +83,7 @@ interface Set { /** * Executes a provided function once per each value in the Set object, in insertion order. */ - forEach(callbackfn: (value: T, value2: T, set: Set) => void, thisArg?: any): void; + forEach(/** @immediate */ callbackfn: (value: T, value2: T, set: Set) => void, thisArg?: any): void; /** * @returns a boolean indicating whether an element with the specified value exists in the Set or not. */ @@ -101,7 +101,7 @@ interface SetConstructor { declare var Set: SetConstructor; interface ReadonlySet { - forEach(callbackfn: (value: T, value2: T, set: ReadonlySet) => void, thisArg?: any): void; + forEach(/** @immediate */ callbackfn: (value: T, value2: T, set: ReadonlySet) => void, thisArg?: any): void; has(value: T): boolean; readonly size: number; } diff --git a/src/lib/es2015.core.d.ts b/src/lib/es2015.core.d.ts index fda087bb55126..09f0f88e28c78 100644 --- a/src/lib/es2015.core.d.ts +++ b/src/lib/es2015.core.d.ts @@ -8,8 +8,8 @@ interface Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find(predicate: (value: T, index: number, obj: T[]) => value is S, thisArg?: any): S | undefined; - find(predicate: (value: T, index: number, obj: T[]) => unknown, thisArg?: any): T | undefined; + find(/** @immediate */ predicate: (value: T, index: number, obj: T[]) => value is S, thisArg?: any): S | undefined; + find(/** @immediate */ predicate: (value: T, index: number, obj: T[]) => unknown, thisArg?: any): T | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -20,7 +20,7 @@ interface Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (value: T, index: number, obj: T[]) => unknown, thisArg?: any): number; + findIndex(/** @immediate */ predicate: (value: T, index: number, obj: T[]) => unknown, thisArg?: any): number; /** * Changes all array elements from `start` to `end` index to a static `value` and returns the modified array @@ -59,7 +59,7 @@ interface ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike, mapfn: (v: T, k: number) => U, thisArg?: any): U[]; + from(arrayLike: ArrayLike, /** @immediate */ mapfn: (v: T, k: number) => U, thisArg?: any): U[]; /** * Returns a new array from a set of elements. @@ -331,8 +331,8 @@ interface ReadonlyArray { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find(predicate: (value: T, index: number, obj: readonly T[]) => value is S, thisArg?: any): S | undefined; - find(predicate: (value: T, index: number, obj: readonly T[]) => unknown, thisArg?: any): T | undefined; + find(/** @immediate */ predicate: (value: T, index: number, obj: readonly T[]) => value is S, thisArg?: any): S | undefined; + find(/** @immediate */ predicate: (value: T, index: number, obj: readonly T[]) => unknown, thisArg?: any): T | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -343,7 +343,7 @@ interface ReadonlyArray { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (value: T, index: number, obj: readonly T[]) => unknown, thisArg?: any): number; + findIndex(/** @immediate */ predicate: (value: T, index: number, obj: readonly T[]) => unknown, thisArg?: any): number; toLocaleString(locales: string | string[], options?: Intl.NumberFormatOptions & Intl.DateTimeFormatOptions): string; } diff --git a/src/lib/es2015.iterable.d.ts b/src/lib/es2015.iterable.d.ts index 50e2277c533e1..dbf6e572fe07d 100644 --- a/src/lib/es2015.iterable.d.ts +++ b/src/lib/es2015.iterable.d.ts @@ -88,7 +88,7 @@ interface ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(iterable: Iterable | ArrayLike, mapfn: (v: T, k: number) => U, thisArg?: any): U[]; + from(iterable: Iterable | ArrayLike, /** @immediate */ mapfn: (v: T, k: number) => U, thisArg?: any): U[]; } interface ReadonlyArray { @@ -277,7 +277,7 @@ interface Int8ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; + from(arrayLike: Iterable, /** @immediate */ mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; } interface Uint8Array { @@ -305,7 +305,7 @@ interface Uint8ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; + from(arrayLike: Iterable, /** @immediate */ mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; } interface Uint8ClampedArray { @@ -335,7 +335,7 @@ interface Uint8ClampedArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; + from(arrayLike: Iterable, /** @immediate */ mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; } interface Int16Array { @@ -365,7 +365,7 @@ interface Int16ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; + from(arrayLike: Iterable, /** @immediate */ mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; } interface Uint16Array { @@ -393,7 +393,7 @@ interface Uint16ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; + from(arrayLike: Iterable, /** @immediate */ mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; } interface Int32Array { @@ -421,7 +421,7 @@ interface Int32ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; + from(arrayLike: Iterable, /** @immediate */ mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; } interface Uint32Array { @@ -449,7 +449,7 @@ interface Uint32ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; + from(arrayLike: Iterable, /** @immediate */ mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; } interface Float32Array { @@ -477,7 +477,7 @@ interface Float32ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; + from(arrayLike: Iterable, /** @immediate */ mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; } interface Float64Array { @@ -505,5 +505,5 @@ interface Float64ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; + from(arrayLike: Iterable, /** @immediate */ mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; } diff --git a/src/lib/es2019.array.d.ts b/src/lib/es2019.array.d.ts index c2da39b76435f..aaa8191f76428 100644 --- a/src/lib/es2019.array.d.ts +++ b/src/lib/es2019.array.d.ts @@ -16,7 +16,7 @@ interface ReadonlyArray { * thisArg is omitted, undefined is used as the this value. */ flatMap( - callback: (this: This, value: T, index: number, array: T[]) => U | ReadonlyArray, + /** @immediate */ callback: (this: This, value: T, index: number, array: T[]) => U | ReadonlyArray, thisArg?: This, ): U[]; @@ -44,7 +44,7 @@ interface Array { * thisArg is omitted, undefined is used as the this value. */ flatMap( - callback: (this: This, value: T, index: number, array: T[]) => U | ReadonlyArray, + /** @immediate */ callback: (this: This, value: T, index: number, array: T[]) => U | ReadonlyArray, thisArg?: This, ): U[]; diff --git a/src/lib/es2020.bigint.d.ts b/src/lib/es2020.bigint.d.ts index 95d2ff245897c..a78bbbb6ad707 100644 --- a/src/lib/es2020.bigint.d.ts +++ b/src/lib/es2020.bigint.d.ts @@ -163,7 +163,7 @@ interface BigInt64Array { * @param thisArg An object to which the this keyword can refer in the predicate function. * If thisArg is omitted, undefined is used as the this value. */ - every(predicate: (value: bigint, index: number, array: BigInt64Array) => boolean, thisArg?: any): boolean; + every(/** @immediate */ predicate: (value: bigint, index: number, array: BigInt64Array) => boolean, thisArg?: any): boolean; /** * Changes all array elements from `start` to `end` index to a static `value` and returns the modified array @@ -182,7 +182,7 @@ interface BigInt64Array { * @param thisArg An object to which the this keyword can refer in the predicate function. * If thisArg is omitted, undefined is used as the this value. */ - filter(predicate: (value: bigint, index: number, array: BigInt64Array) => any, thisArg?: any): BigInt64Array; + filter(/** @immediate */ predicate: (value: bigint, index: number, array: BigInt64Array) => any, thisArg?: any): BigInt64Array; /** * Returns the value of the first element in the array where predicate is true, and undefined @@ -193,7 +193,7 @@ interface BigInt64Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find(predicate: (value: bigint, index: number, array: BigInt64Array) => boolean, thisArg?: any): bigint | undefined; + find(/** @immediate */ predicate: (value: bigint, index: number, array: BigInt64Array) => boolean, thisArg?: any): bigint | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -204,7 +204,7 @@ interface BigInt64Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (value: bigint, index: number, array: BigInt64Array) => boolean, thisArg?: any): number; + findIndex(/** @immediate */ predicate: (value: bigint, index: number, array: BigInt64Array) => boolean, thisArg?: any): number; /** * Performs the specified action for each element in an array. @@ -213,7 +213,7 @@ interface BigInt64Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - forEach(callbackfn: (value: bigint, index: number, array: BigInt64Array) => void, thisArg?: any): void; + forEach(/** @immediate */ callbackfn: (value: bigint, index: number, array: BigInt64Array) => void, thisArg?: any): void; /** * Determines whether an array includes a certain element, returning true or false as appropriate. @@ -259,7 +259,7 @@ interface BigInt64Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - map(callbackfn: (value: bigint, index: number, array: BigInt64Array) => bigint, thisArg?: any): BigInt64Array; + map(/** @immediate */ callbackfn: (value: bigint, index: number, array: BigInt64Array) => bigint, thisArg?: any): BigInt64Array; /** * Calls the specified callback function for all the elements in an array. The return value of @@ -271,7 +271,7 @@ interface BigInt64Array { * the accumulation. The first call to the callbackfn function provides this value as an argument * instead of an array value. */ - reduce(callbackfn: (previousValue: bigint, currentValue: bigint, currentIndex: number, array: BigInt64Array) => bigint): bigint; + reduce(/** @immediate */ callbackfn: (previousValue: bigint, currentValue: bigint, currentIndex: number, array: BigInt64Array) => bigint): bigint; /** * Calls the specified callback function for all the elements in an array. The return value of @@ -283,7 +283,7 @@ interface BigInt64Array { * the accumulation. The first call to the callbackfn function provides this value as an argument * instead of an array value. */ - reduce(callbackfn: (previousValue: U, currentValue: bigint, currentIndex: number, array: BigInt64Array) => U, initialValue: U): U; + reduce(/** @immediate */ callbackfn: (previousValue: U, currentValue: bigint, currentIndex: number, array: BigInt64Array) => U, initialValue: U): U; /** * Calls the specified callback function for all the elements in an array, in descending order. @@ -295,7 +295,7 @@ interface BigInt64Array { * the accumulation. The first call to the callbackfn function provides this value as an * argument instead of an array value. */ - reduceRight(callbackfn: (previousValue: bigint, currentValue: bigint, currentIndex: number, array: BigInt64Array) => bigint): bigint; + reduceRight(/** @immediate */ callbackfn: (previousValue: bigint, currentValue: bigint, currentIndex: number, array: BigInt64Array) => bigint): bigint; /** * Calls the specified callback function for all the elements in an array, in descending order. @@ -307,7 +307,7 @@ interface BigInt64Array { * the accumulation. The first call to the callbackfn function provides this value as an argument * instead of an array value. */ - reduceRight(callbackfn: (previousValue: U, currentValue: bigint, currentIndex: number, array: BigInt64Array) => U, initialValue: U): U; + reduceRight(/** @immediate */ callbackfn: (previousValue: U, currentValue: bigint, currentIndex: number, array: BigInt64Array) => U, initialValue: U): U; /** Reverses the elements in the array. */ reverse(): this; @@ -334,13 +334,13 @@ interface BigInt64Array { * @param thisArg An object to which the this keyword can refer in the predicate function. * If thisArg is omitted, undefined is used as the this value. */ - some(predicate: (value: bigint, index: number, array: BigInt64Array) => boolean, thisArg?: any): boolean; + some(/** @immediate */ predicate: (value: bigint, index: number, array: BigInt64Array) => boolean, thisArg?: any): boolean; /** * Sorts the array. * @param compareFn The function used to determine the order of the elements. If omitted, the elements are sorted in ascending order. */ - sort(compareFn?: (a: bigint, b: bigint) => number | bigint): this; + sort(/** @immediate */ compareFn?: (a: bigint, b: bigint) => number | bigint): this; /** * Gets a new BigInt64Array view of the ArrayBuffer store for this array, referencing the elements @@ -391,7 +391,7 @@ interface BigInt64ArrayConstructor { * @param thisArg Value of 'this' used to invoke the mapfn. */ from(arrayLike: ArrayLike): BigInt64Array; - from(arrayLike: ArrayLike, mapfn: (v: U, k: number) => bigint, thisArg?: any): BigInt64Array; + from(arrayLike: ArrayLike, /** @immediate */ mapfn: (v: U, k: number) => bigint, thisArg?: any): BigInt64Array; } declare var BigInt64Array: BigInt64ArrayConstructor; @@ -435,7 +435,7 @@ interface BigUint64Array { * @param thisArg An object to which the this keyword can refer in the predicate function. * If thisArg is omitted, undefined is used as the this value. */ - every(predicate: (value: bigint, index: number, array: BigUint64Array) => boolean, thisArg?: any): boolean; + every(/** @immediate */ predicate: (value: bigint, index: number, array: BigUint64Array) => boolean, thisArg?: any): boolean; /** * Changes all array elements from `start` to `end` index to a static `value` and returns the modified array @@ -454,7 +454,7 @@ interface BigUint64Array { * @param thisArg An object to which the this keyword can refer in the predicate function. * If thisArg is omitted, undefined is used as the this value. */ - filter(predicate: (value: bigint, index: number, array: BigUint64Array) => any, thisArg?: any): BigUint64Array; + filter(/** @immediate */ predicate: (value: bigint, index: number, array: BigUint64Array) => any, thisArg?: any): BigUint64Array; /** * Returns the value of the first element in the array where predicate is true, and undefined @@ -465,7 +465,7 @@ interface BigUint64Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find(predicate: (value: bigint, index: number, array: BigUint64Array) => boolean, thisArg?: any): bigint | undefined; + find(/** @immediate */ predicate: (value: bigint, index: number, array: BigUint64Array) => boolean, thisArg?: any): bigint | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -476,7 +476,7 @@ interface BigUint64Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (value: bigint, index: number, array: BigUint64Array) => boolean, thisArg?: any): number; + findIndex(/** @immediate */ predicate: (value: bigint, index: number, array: BigUint64Array) => boolean, thisArg?: any): number; /** * Performs the specified action for each element in an array. @@ -485,7 +485,7 @@ interface BigUint64Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - forEach(callbackfn: (value: bigint, index: number, array: BigUint64Array) => void, thisArg?: any): void; + forEach(/** @immediate */ callbackfn: (value: bigint, index: number, array: BigUint64Array) => void, thisArg?: any): void; /** * Determines whether an array includes a certain element, returning true or false as appropriate. @@ -531,7 +531,7 @@ interface BigUint64Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - map(callbackfn: (value: bigint, index: number, array: BigUint64Array) => bigint, thisArg?: any): BigUint64Array; + map(/** @immediate */ callbackfn: (value: bigint, index: number, array: BigUint64Array) => bigint, thisArg?: any): BigUint64Array; /** * Calls the specified callback function for all the elements in an array. The return value of @@ -543,7 +543,7 @@ interface BigUint64Array { * the accumulation. The first call to the callbackfn function provides this value as an argument * instead of an array value. */ - reduce(callbackfn: (previousValue: bigint, currentValue: bigint, currentIndex: number, array: BigUint64Array) => bigint): bigint; + reduce(/** @immediate */ callbackfn: (previousValue: bigint, currentValue: bigint, currentIndex: number, array: BigUint64Array) => bigint): bigint; /** * Calls the specified callback function for all the elements in an array. The return value of @@ -555,7 +555,7 @@ interface BigUint64Array { * the accumulation. The first call to the callbackfn function provides this value as an argument * instead of an array value. */ - reduce(callbackfn: (previousValue: U, currentValue: bigint, currentIndex: number, array: BigUint64Array) => U, initialValue: U): U; + reduce(/** @immediate */ callbackfn: (previousValue: U, currentValue: bigint, currentIndex: number, array: BigUint64Array) => U, initialValue: U): U; /** * Calls the specified callback function for all the elements in an array, in descending order. @@ -567,7 +567,7 @@ interface BigUint64Array { * the accumulation. The first call to the callbackfn function provides this value as an * argument instead of an array value. */ - reduceRight(callbackfn: (previousValue: bigint, currentValue: bigint, currentIndex: number, array: BigUint64Array) => bigint): bigint; + reduceRight(/** @immediate */ callbackfn: (previousValue: bigint, currentValue: bigint, currentIndex: number, array: BigUint64Array) => bigint): bigint; /** * Calls the specified callback function for all the elements in an array, in descending order. @@ -579,7 +579,7 @@ interface BigUint64Array { * the accumulation. The first call to the callbackfn function provides this value as an argument * instead of an array value. */ - reduceRight(callbackfn: (previousValue: U, currentValue: bigint, currentIndex: number, array: BigUint64Array) => U, initialValue: U): U; + reduceRight(/** @immediate */ callbackfn: (previousValue: U, currentValue: bigint, currentIndex: number, array: BigUint64Array) => U, initialValue: U): U; /** Reverses the elements in the array. */ reverse(): this; @@ -606,13 +606,13 @@ interface BigUint64Array { * @param thisArg An object to which the this keyword can refer in the predicate function. * If thisArg is omitted, undefined is used as the this value. */ - some(predicate: (value: bigint, index: number, array: BigUint64Array) => boolean, thisArg?: any): boolean; + some(/** @immediate */ predicate: (value: bigint, index: number, array: BigUint64Array) => boolean, thisArg?: any): boolean; /** * Sorts the array. * @param compareFn The function used to determine the order of the elements. If omitted, the elements are sorted in ascending order. */ - sort(compareFn?: (a: bigint, b: bigint) => number | bigint): this; + sort(/** @immediate */ compareFn?: (a: bigint, b: bigint) => number | bigint): this; /** * Gets a new BigUint64Array view of the ArrayBuffer store for this array, referencing the elements @@ -663,7 +663,7 @@ interface BigUint64ArrayConstructor { * @param thisArg Value of 'this' used to invoke the mapfn. */ from(arrayLike: ArrayLike): BigUint64Array; - from(arrayLike: ArrayLike, mapfn: (v: U, k: number) => bigint, thisArg?: any): BigUint64Array; + from(arrayLike: ArrayLike, /** @immediate */ mapfn: (v: U, k: number) => bigint, thisArg?: any): BigUint64Array; } declare var BigUint64Array: BigUint64ArrayConstructor; diff --git a/src/lib/es2023.array.d.ts b/src/lib/es2023.array.d.ts index b0793a61a6c09..4f01c7634f308 100644 --- a/src/lib/es2023.array.d.ts +++ b/src/lib/es2023.array.d.ts @@ -8,8 +8,8 @@ interface Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findLast(predicate: (value: T, index: number, array: T[]) => value is S, thisArg?: any): S | undefined; - findLast(predicate: (value: T, index: number, array: T[]) => unknown, thisArg?: any): T | undefined; + findLast(/** @immediate */ predicate: (value: T, index: number, array: T[]) => value is S, thisArg?: any): S | undefined; + findLast(/** @immediate */ predicate: (value: T, index: number, array: T[]) => unknown, thisArg?: any): T | undefined; /** * Returns the index of the last element in the array where predicate is true, and -1 @@ -20,7 +20,7 @@ interface Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findLastIndex(predicate: (value: T, index: number, array: T[]) => unknown, thisArg?: any): number; + findLastIndex(/** @immediate */ predicate: (value: T, index: number, array: T[]) => unknown, thisArg?: any): number; /** * Returns a copy of an array with its elements reversed. @@ -36,7 +36,7 @@ interface Array { * [11, 2, 22, 1].toSorted((a, b) => a - b) // [1, 2, 11, 22] * ``` */ - toSorted(compareFn?: (a: T, b: T) => number): T[]; + toSorted(/** @immediate */ compareFn?: (a: T, b: T) => number): T[]; /** * Copies an array and removes elements and, if necessary, inserts new elements in their place. Returns the copied array. @@ -78,11 +78,11 @@ interface ReadonlyArray { * predicate. If it is not provided, undefined is used instead. */ findLast( - predicate: (value: T, index: number, array: readonly T[]) => value is S, + /** @immediate */ predicate: (value: T, index: number, array: readonly T[]) => value is S, thisArg?: any, ): S | undefined; findLast( - predicate: (value: T, index: number, array: readonly T[]) => unknown, + /** @immediate */ predicate: (value: T, index: number, array: readonly T[]) => unknown, thisArg?: any, ): T | undefined; @@ -96,7 +96,7 @@ interface ReadonlyArray { * predicate. If it is not provided, undefined is used instead. */ findLastIndex( - predicate: (value: T, index: number, array: readonly T[]) => unknown, + /** @immediate */ predicate: (value: T, index: number, array: readonly T[]) => unknown, thisArg?: any, ): number; @@ -114,7 +114,7 @@ interface ReadonlyArray { * [11, 2, 22, 1].toSorted((a, b) => a - b) // [1, 2, 11, 22] * ``` */ - toSorted(compareFn?: (a: T, b: T) => number): T[]; + toSorted(/** @immediate */ compareFn?: (a: T, b: T) => number): T[]; /** * Copies an array and removes elements while, if necessary, inserting new elements in their place, returning the remaining elements. @@ -156,7 +156,7 @@ interface Int8Array { * predicate. If it is not provided, undefined is used instead. */ findLast( - predicate: ( + /** @immediate */ predicate: ( value: number, index: number, array: Int8Array, @@ -164,7 +164,7 @@ interface Int8Array { thisArg?: any, ): S | undefined; findLast( - predicate: (value: number, index: number, array: Int8Array) => unknown, + /** @immediate */ predicate: (value: number, index: number, array: Int8Array) => unknown, thisArg?: any, ): number | undefined; @@ -178,7 +178,7 @@ interface Int8Array { * predicate. If it is not provided, undefined is used instead. */ findLastIndex( - predicate: (value: number, index: number, array: Int8Array) => unknown, + /** @immediate */ predicate: (value: number, index: number, array: Int8Array) => unknown, thisArg?: any, ): number; @@ -197,7 +197,7 @@ interface Int8Array { * myNums.toSorted((a, b) => a - b) // Int8Array(4) [1, 2, 11, 22] * ``` */ - toSorted(compareFn?: (a: number, b: number) => number): Int8Array; + toSorted(/** @immediate */ compareFn?: (a: number, b: number) => number): Int8Array; /** * Copies the array and inserts the given number at the provided index. @@ -220,7 +220,7 @@ interface Uint8Array { * predicate. If it is not provided, undefined is used instead. */ findLast( - predicate: ( + /** @immediate */ predicate: ( value: number, index: number, array: Uint8Array, @@ -228,7 +228,7 @@ interface Uint8Array { thisArg?: any, ): S | undefined; findLast( - predicate: (value: number, index: number, array: Uint8Array) => unknown, + /** @immediate */ predicate: (value: number, index: number, array: Uint8Array) => unknown, thisArg?: any, ): number | undefined; @@ -242,7 +242,7 @@ interface Uint8Array { * predicate. If it is not provided, undefined is used instead. */ findLastIndex( - predicate: (value: number, index: number, array: Uint8Array) => unknown, + /** @immediate */ predicate: (value: number, index: number, array: Uint8Array) => unknown, thisArg?: any, ): number; @@ -261,7 +261,7 @@ interface Uint8Array { * myNums.toSorted((a, b) => a - b) // Uint8Array(4) [1, 2, 11, 22] * ``` */ - toSorted(compareFn?: (a: number, b: number) => number): Uint8Array; + toSorted(/** @immediate */ compareFn?: (a: number, b: number) => number): Uint8Array; /** * Copies the array and inserts the given number at the provided index. @@ -284,7 +284,7 @@ interface Uint8ClampedArray { * predicate. If it is not provided, undefined is used instead. */ findLast( - predicate: ( + /** @immediate */ predicate: ( value: number, index: number, array: Uint8ClampedArray, @@ -292,7 +292,7 @@ interface Uint8ClampedArray { thisArg?: any, ): S | undefined; findLast( - predicate: ( + /** @immediate */ predicate: ( value: number, index: number, array: Uint8ClampedArray, @@ -310,7 +310,7 @@ interface Uint8ClampedArray { * predicate. If it is not provided, undefined is used instead. */ findLastIndex( - predicate: ( + /** @immediate */ predicate: ( value: number, index: number, array: Uint8ClampedArray, @@ -333,7 +333,7 @@ interface Uint8ClampedArray { * myNums.toSorted((a, b) => a - b) // Uint8ClampedArray(4) [1, 2, 11, 22] * ``` */ - toSorted(compareFn?: (a: number, b: number) => number): Uint8ClampedArray; + toSorted(/** @immediate */ compareFn?: (a: number, b: number) => number): Uint8ClampedArray; /** * Copies the array and inserts the given number at the provided index. @@ -356,7 +356,7 @@ interface Int16Array { * predicate. If it is not provided, undefined is used instead. */ findLast( - predicate: ( + /** @immediate */ predicate: ( value: number, index: number, array: Int16Array, @@ -364,7 +364,7 @@ interface Int16Array { thisArg?: any, ): S | undefined; findLast( - predicate: (value: number, index: number, array: Int16Array) => unknown, + /** @immediate */ predicate: (value: number, index: number, array: Int16Array) => unknown, thisArg?: any, ): number | undefined; @@ -378,7 +378,7 @@ interface Int16Array { * predicate. If it is not provided, undefined is used instead. */ findLastIndex( - predicate: (value: number, index: number, array: Int16Array) => unknown, + /** @immediate */ predicate: (value: number, index: number, array: Int16Array) => unknown, thisArg?: any, ): number; @@ -397,7 +397,7 @@ interface Int16Array { * myNums.toSorted((a, b) => a - b) // Int16Array(4) [-22, 1, 2, 11] * ``` */ - toSorted(compareFn?: (a: number, b: number) => number): Int16Array; + toSorted(/** @immediate */ compareFn?: (a: number, b: number) => number): Int16Array; /** * Copies the array and inserts the given number at the provided index. @@ -420,7 +420,7 @@ interface Uint16Array { * predicate. If it is not provided, undefined is used instead. */ findLast( - predicate: ( + /** @immediate */ predicate: ( value: number, index: number, array: Uint16Array, @@ -428,7 +428,7 @@ interface Uint16Array { thisArg?: any, ): S | undefined; findLast( - predicate: ( + /** @immediate */ predicate: ( value: number, index: number, array: Uint16Array, @@ -446,7 +446,7 @@ interface Uint16Array { * predicate. If it is not provided, undefined is used instead. */ findLastIndex( - predicate: ( + /** @immediate */ predicate: ( value: number, index: number, array: Uint16Array, @@ -469,7 +469,7 @@ interface Uint16Array { * myNums.toSorted((a, b) => a - b) // Uint16Array(4) [1, 2, 11, 22] * ``` */ - toSorted(compareFn?: (a: number, b: number) => number): Uint16Array; + toSorted(/** @immediate */ compareFn?: (a: number, b: number) => number): Uint16Array; /** * Copies the array and inserts the given number at the provided index. @@ -492,7 +492,7 @@ interface Int32Array { * predicate. If it is not provided, undefined is used instead. */ findLast( - predicate: ( + /** @immediate */ predicate: ( value: number, index: number, array: Int32Array, @@ -500,7 +500,7 @@ interface Int32Array { thisArg?: any, ): S | undefined; findLast( - predicate: (value: number, index: number, array: Int32Array) => unknown, + /** @immediate */ predicate: (value: number, index: number, array: Int32Array) => unknown, thisArg?: any, ): number | undefined; @@ -514,7 +514,7 @@ interface Int32Array { * predicate. If it is not provided, undefined is used instead. */ findLastIndex( - predicate: (value: number, index: number, array: Int32Array) => unknown, + /** @immediate */ predicate: (value: number, index: number, array: Int32Array) => unknown, thisArg?: any, ): number; @@ -533,7 +533,7 @@ interface Int32Array { * myNums.toSorted((a, b) => a - b) // Int32Array(4) [-22, 1, 2, 11] * ``` */ - toSorted(compareFn?: (a: number, b: number) => number): Int32Array; + toSorted(/** @immediate */ compareFn?: (a: number, b: number) => number): Int32Array; /** * Copies the array and inserts the given number at the provided index. @@ -556,7 +556,7 @@ interface Uint32Array { * predicate. If it is not provided, undefined is used instead. */ findLast( - predicate: ( + /** @immediate */ predicate: ( value: number, index: number, array: Uint32Array, @@ -564,7 +564,7 @@ interface Uint32Array { thisArg?: any, ): S | undefined; findLast( - predicate: ( + /** @immediate */ predicate: ( value: number, index: number, array: Uint32Array, @@ -582,7 +582,7 @@ interface Uint32Array { * predicate. If it is not provided, undefined is used instead. */ findLastIndex( - predicate: ( + /** @immediate */ predicate: ( value: number, index: number, array: Uint32Array, @@ -605,7 +605,7 @@ interface Uint32Array { * myNums.toSorted((a, b) => a - b) // Uint32Array(4) [1, 2, 11, 22] * ``` */ - toSorted(compareFn?: (a: number, b: number) => number): Uint32Array; + toSorted(/** @immediate */ compareFn?: (a: number, b: number) => number): Uint32Array; /** * Copies the array and inserts the given number at the provided index. @@ -628,7 +628,7 @@ interface Float32Array { * predicate. If it is not provided, undefined is used instead. */ findLast( - predicate: ( + /** @immediate */ predicate: ( value: number, index: number, array: Float32Array, @@ -636,7 +636,7 @@ interface Float32Array { thisArg?: any, ): S | undefined; findLast( - predicate: ( + /** @immediate */ predicate: ( value: number, index: number, array: Float32Array, @@ -654,7 +654,7 @@ interface Float32Array { * predicate. If it is not provided, undefined is used instead. */ findLastIndex( - predicate: ( + /** @immediate */ predicate: ( value: number, index: number, array: Float32Array, @@ -677,7 +677,7 @@ interface Float32Array { * myNums.toSorted((a, b) => a - b) // Float32Array(4) [-22.5, 1, 2, 11.5] * ``` */ - toSorted(compareFn?: (a: number, b: number) => number): Float32Array; + toSorted(/** @immediate */ compareFn?: (a: number, b: number) => number): Float32Array; /** * Copies the array and inserts the given number at the provided index. @@ -700,7 +700,7 @@ interface Float64Array { * predicate. If it is not provided, undefined is used instead. */ findLast( - predicate: ( + /** @immediate */ predicate: ( value: number, index: number, array: Float64Array, @@ -708,7 +708,7 @@ interface Float64Array { thisArg?: any, ): S | undefined; findLast( - predicate: ( + /** @immediate */ predicate: ( value: number, index: number, array: Float64Array, @@ -726,7 +726,7 @@ interface Float64Array { * predicate. If it is not provided, undefined is used instead. */ findLastIndex( - predicate: ( + /** @immediate */ predicate: ( value: number, index: number, array: Float64Array, @@ -749,7 +749,7 @@ interface Float64Array { * myNums.toSorted((a, b) => a - b) // Float64Array(4) [-22.5, 1, 2, 11.5] * ``` */ - toSorted(compareFn?: (a: number, b: number) => number): Float64Array; + toSorted(/** @immediate */ compareFn?: (a: number, b: number) => number): Float64Array; /** * Copies the array and inserts the given number at the provided index. @@ -772,7 +772,7 @@ interface BigInt64Array { * predicate. If it is not provided, undefined is used instead. */ findLast( - predicate: ( + /** @immediate */ predicate: ( value: bigint, index: number, array: BigInt64Array, @@ -780,7 +780,7 @@ interface BigInt64Array { thisArg?: any, ): S | undefined; findLast( - predicate: ( + /** @immediate */ predicate: ( value: bigint, index: number, array: BigInt64Array, @@ -798,7 +798,7 @@ interface BigInt64Array { * predicate. If it is not provided, undefined is used instead. */ findLastIndex( - predicate: ( + /** @immediate */ predicate: ( value: bigint, index: number, array: BigInt64Array, @@ -821,7 +821,7 @@ interface BigInt64Array { * myNums.toSorted((a, b) => Number(a - b)) // BigInt64Array(4) [-22n, 1n, 2n, 11n] * ``` */ - toSorted(compareFn?: (a: bigint, b: bigint) => number): BigInt64Array; + toSorted(/** @immediate */ compareFn?: (a: bigint, b: bigint) => number): BigInt64Array; /** * Copies the array and inserts the given bigint at the provided index. @@ -844,7 +844,7 @@ interface BigUint64Array { * predicate. If it is not provided, undefined is used instead. */ findLast( - predicate: ( + /** @immediate */ predicate: ( value: bigint, index: number, array: BigUint64Array, @@ -852,7 +852,7 @@ interface BigUint64Array { thisArg?: any, ): S | undefined; findLast( - predicate: ( + /** @immediate */ predicate: ( value: bigint, index: number, array: BigUint64Array, @@ -870,7 +870,7 @@ interface BigUint64Array { * predicate. If it is not provided, undefined is used instead. */ findLastIndex( - predicate: ( + /** @immediate */ predicate: ( value: bigint, index: number, array: BigUint64Array, @@ -893,7 +893,7 @@ interface BigUint64Array { * myNums.toSorted((a, b) => Number(a - b)) // BigUint64Array(4) [1n, 2n, 11n, 22n] * ``` */ - toSorted(compareFn?: (a: bigint, b: bigint) => number): BigUint64Array; + toSorted(/** @immediate */ compareFn?: (a: bigint, b: bigint) => number): BigUint64Array; /** * Copies the array and inserts the given bigint at the provided index. diff --git a/src/lib/es5.d.ts b/src/lib/es5.d.ts index 33bbb99147490..3251bb480d094 100644 --- a/src/lib/es5.d.ts +++ b/src/lib/es5.d.ts @@ -449,7 +449,7 @@ interface String { * @param searchValue A string to search for. * @param replacer A function that returns the replacement text. */ - replace(searchValue: string | RegExp, replacer: (substring: string, ...args: any[]) => string): string; + replace(searchValue: string | RegExp, /** @immediate */ replacer: (substring: string, ...args: any[]) => string): string; /** * Finds the first substring match in a regular expression search. @@ -1141,14 +1141,14 @@ interface JSON { * @param reviver A function that transforms the results. This function is called for each member of the object. * If a member contains nested objects, the nested objects are transformed before the parent object is. */ - parse(text: string, reviver?: (this: any, key: string, value: any) => any): any; + parse(text: string, /** @immediate */ reviver?: (this: any, key: string, value: any) => any): any; /** * Converts a JavaScript value to a JavaScript Object Notation (JSON) string. * @param value A JavaScript value, usually an object or array, to be converted. * @param replacer A function that transforms the results. * @param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read. */ - stringify(value: any, replacer?: (this: any, key: string, value: any) => any, space?: string | number): string; + stringify(value: any, /** @immediate */ replacer?: (this: any, key: string, value: any) => any, space?: string | number): string; /** * Converts a JavaScript value to a JavaScript Object Notation (JSON) string. * @param value A JavaScript value, usually an object or array, to be converted. @@ -1221,7 +1221,7 @@ interface ReadonlyArray { * @param thisArg An object to which the this keyword can refer in the predicate function. * If thisArg is omitted, undefined is used as the this value. */ - every(predicate: (value: T, index: number, array: readonly T[]) => value is S, thisArg?: any): this is readonly S[]; + every(/** @immediate */ predicate: (value: T, index: number, array: readonly T[]) => value is S, thisArg?: any): this is readonly S[]; /** * Determines whether all the members of an array satisfy the specified test. * @param predicate A function that accepts up to three arguments. The every method calls @@ -1230,7 +1230,7 @@ interface ReadonlyArray { * @param thisArg An object to which the this keyword can refer in the predicate function. * If thisArg is omitted, undefined is used as the this value. */ - every(predicate: (value: T, index: number, array: readonly T[]) => unknown, thisArg?: any): boolean; + every(/** @immediate */ predicate: (value: T, index: number, array: readonly T[]) => unknown, thisArg?: any): boolean; /** * Determines whether the specified callback function returns true for any element of an array. * @param predicate A function that accepts up to three arguments. The some method calls @@ -1239,57 +1239,57 @@ interface ReadonlyArray { * @param thisArg An object to which the this keyword can refer in the predicate function. * If thisArg is omitted, undefined is used as the this value. */ - some(predicate: (value: T, index: number, array: readonly T[]) => unknown, thisArg?: any): boolean; + some(/** @immediate */ predicate: (value: T, index: number, array: readonly T[]) => unknown, thisArg?: any): boolean; /** * Performs the specified action for each element in an array. * @param callbackfn A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the array. * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. */ - forEach(callbackfn: (value: T, index: number, array: readonly T[]) => void, thisArg?: any): void; + forEach(/** @immediate */ callbackfn: (value: T, index: number, array: readonly T[]) => void, thisArg?: any): void; /** * Calls a defined callback function on each element of an array, and returns an array that contains the results. * @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array. * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. */ - map(callbackfn: (value: T, index: number, array: readonly T[]) => U, thisArg?: any): U[]; + map(/** @immediate */ callbackfn: (value: T, index: number, array: readonly T[]) => U, thisArg?: any): U[]; /** * Returns the elements of an array that meet the condition specified in a callback function. * @param predicate A function that accepts up to three arguments. The filter method calls the predicate function one time for each element in the array. * @param thisArg An object to which the this keyword can refer in the predicate function. If thisArg is omitted, undefined is used as the this value. */ - filter(predicate: (value: T, index: number, array: readonly T[]) => value is S, thisArg?: any): S[]; + filter(/** @immediate */ predicate: (value: T, index: number, array: readonly T[]) => value is S, thisArg?: any): S[]; /** * Returns the elements of an array that meet the condition specified in a callback function. * @param predicate A function that accepts up to three arguments. The filter method calls the predicate function one time for each element in the array. * @param thisArg An object to which the this keyword can refer in the predicate function. If thisArg is omitted, undefined is used as the this value. */ - filter(predicate: (value: T, index: number, array: readonly T[]) => unknown, thisArg?: any): T[]; + filter(/** @immediate */ predicate: (value: T, index: number, array: readonly T[]) => unknown, thisArg?: any): T[]; /** * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array. * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. */ - reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: readonly T[]) => T): T; - reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: readonly T[]) => T, initialValue: T): T; + reduce(/** @immediate */ callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: readonly T[]) => T): T; + reduce(/** @immediate */ callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: readonly T[]) => T, initialValue: T): T; /** * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array. * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. */ - reduce(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: readonly T[]) => U, initialValue: U): U; + reduce(/** @immediate */ callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: readonly T[]) => U, initialValue: U): U; /** * Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array. * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. */ - reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: readonly T[]) => T): T; - reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: readonly T[]) => T, initialValue: T): T; + reduceRight(/** @immediate */ callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: readonly T[]) => T): T; + reduceRight(/** @immediate */ callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: readonly T[]) => T, initialValue: T): T; /** * Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array. * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. */ - reduceRight(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: readonly T[]) => U, initialValue: U): U; + reduceRight(/** @immediate */ callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: readonly T[]) => U, initialValue: U): U; readonly [n: number]: T; } @@ -1371,7 +1371,7 @@ interface Array { * [11,2,22,1].sort((a, b) => a - b) * ``` */ - sort(compareFn?: (a: T, b: T) => number): this; + sort(/** @immediate */ compareFn?: (a: T, b: T) => number): this; /** * Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. * @param start The zero-based location in the array from which to start removing elements. @@ -1412,7 +1412,7 @@ interface Array { * @param thisArg An object to which the this keyword can refer in the predicate function. * If thisArg is omitted, undefined is used as the this value. */ - every(predicate: (value: T, index: number, array: T[]) => value is S, thisArg?: any): this is S[]; + every(/** @immediate */ predicate: (value: T, index: number, array: T[]) => value is S, thisArg?: any): this is S[]; /** * Determines whether all the members of an array satisfy the specified test. * @param predicate A function that accepts up to three arguments. The every method calls @@ -1421,7 +1421,7 @@ interface Array { * @param thisArg An object to which the this keyword can refer in the predicate function. * If thisArg is omitted, undefined is used as the this value. */ - every(predicate: (value: T, index: number, array: T[]) => unknown, thisArg?: any): boolean; + every(/** @immediate */ predicate: (value: T, index: number, array: T[]) => unknown, thisArg?: any): boolean; /** * Determines whether the specified callback function returns true for any element of an array. * @param predicate A function that accepts up to three arguments. The some method calls @@ -1430,57 +1430,57 @@ interface Array { * @param thisArg An object to which the this keyword can refer in the predicate function. * If thisArg is omitted, undefined is used as the this value. */ - some(predicate: (value: T, index: number, array: T[]) => unknown, thisArg?: any): boolean; + some(/** @immediate */ predicate: (value: T, index: number, array: T[]) => unknown, thisArg?: any): boolean; /** * Performs the specified action for each element in an array. * @param callbackfn A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the array. * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. */ - forEach(callbackfn: (value: T, index: number, array: T[]) => void, thisArg?: any): void; + forEach(/** @immediate */ callbackfn: (value: T, index: number, array: T[]) => void, thisArg?: any): void; /** * Calls a defined callback function on each element of an array, and returns an array that contains the results. * @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array. * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. */ - map(callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): U[]; + map(/** @immediate */ callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): U[]; /** * Returns the elements of an array that meet the condition specified in a callback function. * @param predicate A function that accepts up to three arguments. The filter method calls the predicate function one time for each element in the array. * @param thisArg An object to which the this keyword can refer in the predicate function. If thisArg is omitted, undefined is used as the this value. */ - filter(predicate: (value: T, index: number, array: T[]) => value is S, thisArg?: any): S[]; + filter(/** @immediate */ predicate: (value: T, index: number, array: T[]) => value is S, thisArg?: any): S[]; /** * Returns the elements of an array that meet the condition specified in a callback function. * @param predicate A function that accepts up to three arguments. The filter method calls the predicate function one time for each element in the array. * @param thisArg An object to which the this keyword can refer in the predicate function. If thisArg is omitted, undefined is used as the this value. */ - filter(predicate: (value: T, index: number, array: T[]) => unknown, thisArg?: any): T[]; + filter(/** @immediate */ predicate: (value: T, index: number, array: T[]) => unknown, thisArg?: any): T[]; /** * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array. * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. */ - reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T): T; - reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue: T): T; + reduce(/** @immediate */ callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T): T; + reduce(/** @immediate */ callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue: T): T; /** * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array. * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. */ - reduce(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; + reduce(/** @immediate */ callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; /** * Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array. * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. */ - reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T): T; - reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue: T): T; + reduceRight(/** @immediate */ callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T): T; + reduceRight(/** @immediate */ callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue: T): T; /** * Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array. * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. */ - reduceRight(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; + reduceRight(/** @immediate */ callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; [n: number]: T; } @@ -1896,7 +1896,7 @@ interface Int8Array { * @param thisArg An object to which the this keyword can refer in the predicate function. * If thisArg is omitted, undefined is used as the this value. */ - every(predicate: (value: number, index: number, array: Int8Array) => unknown, thisArg?: any): boolean; + every(/** @immediate */ predicate: (value: number, index: number, array: Int8Array) => unknown, thisArg?: any): boolean; /** * Changes all array elements from `start` to `end` index to a static `value` and returns the modified array @@ -1915,7 +1915,7 @@ interface Int8Array { * @param thisArg An object to which the this keyword can refer in the predicate function. * If thisArg is omitted, undefined is used as the this value. */ - filter(predicate: (value: number, index: number, array: Int8Array) => any, thisArg?: any): Int8Array; + filter(/** @immediate */ predicate: (value: number, index: number, array: Int8Array) => any, thisArg?: any): Int8Array; /** * Returns the value of the first element in the array where predicate is true, and undefined @@ -1926,7 +1926,7 @@ interface Int8Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find(predicate: (value: number, index: number, obj: Int8Array) => boolean, thisArg?: any): number | undefined; + find(/** @immediate */ predicate: (value: number, index: number, obj: Int8Array) => boolean, thisArg?: any): number | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -1937,7 +1937,7 @@ interface Int8Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (value: number, index: number, obj: Int8Array) => boolean, thisArg?: any): number; + findIndex(/** @immediate */ predicate: (value: number, index: number, obj: Int8Array) => boolean, thisArg?: any): number; /** * Performs the specified action for each element in an array. @@ -1946,7 +1946,7 @@ interface Int8Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - forEach(callbackfn: (value: number, index: number, array: Int8Array) => void, thisArg?: any): void; + forEach(/** @immediate */ callbackfn: (value: number, index: number, array: Int8Array) => void, thisArg?: any): void; /** * Returns the index of the first occurrence of a value in an array. @@ -1984,7 +1984,7 @@ interface Int8Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - map(callbackfn: (value: number, index: number, array: Int8Array) => number, thisArg?: any): Int8Array; + map(/** @immediate */ callbackfn: (value: number, index: number, array: Int8Array) => number, thisArg?: any): Int8Array; /** * Calls the specified callback function for all the elements in an array. The return value of @@ -1996,8 +1996,8 @@ interface Int8Array { * the accumulation. The first call to the callbackfn function provides this value as an argument * instead of an array value. */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int8Array) => number): number; - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int8Array) => number, initialValue: number): number; + reduce(/** @immediate */ callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int8Array) => number): number; + reduce(/** @immediate */ callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int8Array) => number, initialValue: number): number; /** * Calls the specified callback function for all the elements in an array. The return value of @@ -2009,7 +2009,7 @@ interface Int8Array { * the accumulation. The first call to the callbackfn function provides this value as an argument * instead of an array value. */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int8Array) => U, initialValue: U): U; + reduce(/** @immediate */ callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int8Array) => U, initialValue: U): U; /** * Calls the specified callback function for all the elements in an array, in descending order. @@ -2021,8 +2021,8 @@ interface Int8Array { * the accumulation. The first call to the callbackfn function provides this value as an * argument instead of an array value. */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int8Array) => number): number; - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int8Array) => number, initialValue: number): number; + reduceRight(/** @immediate */ callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int8Array) => number): number; + reduceRight(/** @immediate */ callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int8Array) => number, initialValue: number): number; /** * Calls the specified callback function for all the elements in an array, in descending order. @@ -2034,7 +2034,7 @@ interface Int8Array { * the accumulation. The first call to the callbackfn function provides this value as an argument * instead of an array value. */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int8Array) => U, initialValue: U): U; + reduceRight(/** @immediate */ callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int8Array) => U, initialValue: U): U; /** * Reverses the elements in an Array. @@ -2063,7 +2063,7 @@ interface Int8Array { * @param thisArg An object to which the this keyword can refer in the predicate function. * If thisArg is omitted, undefined is used as the this value. */ - some(predicate: (value: number, index: number, array: Int8Array) => unknown, thisArg?: any): boolean; + some(/** @immediate */ predicate: (value: number, index: number, array: Int8Array) => unknown, thisArg?: any): boolean; /** * Sorts an array. @@ -2074,7 +2074,7 @@ interface Int8Array { * [11,2,22,1].sort((a, b) => a - b) * ``` */ - sort(compareFn?: (a: number, b: number) => number): this; + sort(/** @immediate */ comparefn?: (a: number, b: number) => number): this; /** * Gets a new Int8Array view of the ArrayBuffer store for this array, referencing the elements @@ -2128,7 +2128,7 @@ interface Int8ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Int8Array; + from(arrayLike: ArrayLike, /** @immediate */ mapfn: (v: T, k: number) => number, thisArg?: any): Int8Array; } declare var Int8Array: Int8ArrayConstructor; @@ -2176,7 +2176,7 @@ interface Uint8Array { * @param thisArg An object to which the this keyword can refer in the predicate function. * If thisArg is omitted, undefined is used as the this value. */ - every(predicate: (value: number, index: number, array: Uint8Array) => unknown, thisArg?: any): boolean; + every(/** @immediate */ predicate: (value: number, index: number, array: Uint8Array) => unknown, thisArg?: any): boolean; /** * Changes all array elements from `start` to `end` index to a static `value` and returns the modified array @@ -2195,7 +2195,7 @@ interface Uint8Array { * @param thisArg An object to which the this keyword can refer in the predicate function. * If thisArg is omitted, undefined is used as the this value. */ - filter(predicate: (value: number, index: number, array: Uint8Array) => any, thisArg?: any): Uint8Array; + filter(/** @immediate */ predicate: (value: number, index: number, array: Uint8Array) => any, thisArg?: any): Uint8Array; /** * Returns the value of the first element in the array where predicate is true, and undefined @@ -2206,7 +2206,7 @@ interface Uint8Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find(predicate: (value: number, index: number, obj: Uint8Array) => boolean, thisArg?: any): number | undefined; + find(/** @immediate */ predicate: (value: number, index: number, obj: Uint8Array) => boolean, thisArg?: any): number | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -2217,7 +2217,7 @@ interface Uint8Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (value: number, index: number, obj: Uint8Array) => boolean, thisArg?: any): number; + findIndex(/** @immediate */ predicate: (value: number, index: number, obj: Uint8Array) => boolean, thisArg?: any): number; /** * Performs the specified action for each element in an array. @@ -2226,7 +2226,7 @@ interface Uint8Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - forEach(callbackfn: (value: number, index: number, array: Uint8Array) => void, thisArg?: any): void; + forEach(/** @immediate */ callbackfn: (value: number, index: number, array: Uint8Array) => void, thisArg?: any): void; /** * Returns the index of the first occurrence of a value in an array. @@ -2264,7 +2264,7 @@ interface Uint8Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - map(callbackfn: (value: number, index: number, array: Uint8Array) => number, thisArg?: any): Uint8Array; + map(/** @immediate */ callbackfn: (value: number, index: number, array: Uint8Array) => number, thisArg?: any): Uint8Array; /** * Calls the specified callback function for all the elements in an array. The return value of @@ -2276,8 +2276,8 @@ interface Uint8Array { * the accumulation. The first call to the callbackfn function provides this value as an argument * instead of an array value. */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8Array) => number): number; - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8Array) => number, initialValue: number): number; + reduce(/** @immediate */ callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8Array) => number): number; + reduce(/** @immediate */ callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8Array) => number, initialValue: number): number; /** * Calls the specified callback function for all the elements in an array. The return value of @@ -2289,7 +2289,7 @@ interface Uint8Array { * the accumulation. The first call to the callbackfn function provides this value as an argument * instead of an array value. */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8Array) => U, initialValue: U): U; + reduce(/** @immediate */ callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8Array) => U, initialValue: U): U; /** * Calls the specified callback function for all the elements in an array, in descending order. @@ -2301,8 +2301,8 @@ interface Uint8Array { * the accumulation. The first call to the callbackfn function provides this value as an * argument instead of an array value. */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8Array) => number): number; - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8Array) => number, initialValue: number): number; + reduceRight(/** @immediate */ callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8Array) => number): number; + reduceRight(/** @immediate */ callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8Array) => number, initialValue: number): number; /** * Calls the specified callback function for all the elements in an array, in descending order. @@ -2314,7 +2314,7 @@ interface Uint8Array { * the accumulation. The first call to the callbackfn function provides this value as an argument * instead of an array value. */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8Array) => U, initialValue: U): U; + reduceRight(/** @immediate */ callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8Array) => U, initialValue: U): U; /** * Reverses the elements in an Array. @@ -2343,7 +2343,7 @@ interface Uint8Array { * @param thisArg An object to which the this keyword can refer in the predicate function. * If thisArg is omitted, undefined is used as the this value. */ - some(predicate: (value: number, index: number, array: Uint8Array) => unknown, thisArg?: any): boolean; + some(/** @immediate */ predicate: (value: number, index: number, array: Uint8Array) => unknown, thisArg?: any): boolean; /** * Sorts an array. @@ -2354,7 +2354,7 @@ interface Uint8Array { * [11,2,22,1].sort((a, b) => a - b) * ``` */ - sort(compareFn?: (a: number, b: number) => number): this; + sort(/** @immediate */ comparefn?: (a: number, b: number) => number): this; /** * Gets a new Uint8Array view of the ArrayBuffer store for this array, referencing the elements @@ -2409,7 +2409,7 @@ interface Uint8ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Uint8Array; + from(arrayLike: ArrayLike, /** @immediate */ mapfn: (v: T, k: number) => number, thisArg?: any): Uint8Array; } declare var Uint8Array: Uint8ArrayConstructor; @@ -2457,7 +2457,7 @@ interface Uint8ClampedArray { * @param thisArg An object to which the this keyword can refer in the predicate function. * If thisArg is omitted, undefined is used as the this value. */ - every(predicate: (value: number, index: number, array: Uint8ClampedArray) => unknown, thisArg?: any): boolean; + every(/** @immediate */ predicate: (value: number, index: number, array: Uint8ClampedArray) => unknown, thisArg?: any): boolean; /** * Changes all array elements from `start` to `end` index to a static `value` and returns the modified array @@ -2476,7 +2476,7 @@ interface Uint8ClampedArray { * @param thisArg An object to which the this keyword can refer in the predicate function. * If thisArg is omitted, undefined is used as the this value. */ - filter(predicate: (value: number, index: number, array: Uint8ClampedArray) => any, thisArg?: any): Uint8ClampedArray; + filter(/** @immediate */ predicate: (value: number, index: number, array: Uint8ClampedArray) => any, thisArg?: any): Uint8ClampedArray; /** * Returns the value of the first element in the array where predicate is true, and undefined @@ -2487,7 +2487,7 @@ interface Uint8ClampedArray { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find(predicate: (value: number, index: number, obj: Uint8ClampedArray) => boolean, thisArg?: any): number | undefined; + find(/** @immediate */ predicate: (value: number, index: number, obj: Uint8ClampedArray) => boolean, thisArg?: any): number | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -2498,7 +2498,7 @@ interface Uint8ClampedArray { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (value: number, index: number, obj: Uint8ClampedArray) => boolean, thisArg?: any): number; + findIndex(/** @immediate */ predicate: (value: number, index: number, obj: Uint8ClampedArray) => boolean, thisArg?: any): number; /** * Performs the specified action for each element in an array. @@ -2507,7 +2507,7 @@ interface Uint8ClampedArray { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - forEach(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => void, thisArg?: any): void; + forEach(/** @immediate */ callbackfn: (value: number, index: number, array: Uint8ClampedArray) => void, thisArg?: any): void; /** * Returns the index of the first occurrence of a value in an array. @@ -2545,7 +2545,7 @@ interface Uint8ClampedArray { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - map(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => number, thisArg?: any): Uint8ClampedArray; + map(/** @immediate */ callbackfn: (value: number, index: number, array: Uint8ClampedArray) => number, thisArg?: any): Uint8ClampedArray; /** * Calls the specified callback function for all the elements in an array. The return value of @@ -2557,8 +2557,8 @@ interface Uint8ClampedArray { * the accumulation. The first call to the callbackfn function provides this value as an argument * instead of an array value. */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => number): number; - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => number, initialValue: number): number; + reduce(/** @immediate */ callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => number): number; + reduce(/** @immediate */ callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => number, initialValue: number): number; /** * Calls the specified callback function for all the elements in an array. The return value of @@ -2570,7 +2570,7 @@ interface Uint8ClampedArray { * the accumulation. The first call to the callbackfn function provides this value as an argument * instead of an array value. */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => U, initialValue: U): U; + reduce(/** @immediate */ callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => U, initialValue: U): U; /** * Calls the specified callback function for all the elements in an array, in descending order. @@ -2582,8 +2582,8 @@ interface Uint8ClampedArray { * the accumulation. The first call to the callbackfn function provides this value as an * argument instead of an array value. */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => number): number; - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => number, initialValue: number): number; + reduceRight(/** @immediate */ callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => number): number; + reduceRight(/** @immediate */ callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => number, initialValue: number): number; /** * Calls the specified callback function for all the elements in an array, in descending order. @@ -2595,7 +2595,7 @@ interface Uint8ClampedArray { * the accumulation. The first call to the callbackfn function provides this value as an argument * instead of an array value. */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => U, initialValue: U): U; + reduceRight(/** @immediate */ callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => U, initialValue: U): U; /** * Reverses the elements in an Array. @@ -2624,7 +2624,7 @@ interface Uint8ClampedArray { * @param thisArg An object to which the this keyword can refer in the predicate function. * If thisArg is omitted, undefined is used as the this value. */ - some(predicate: (value: number, index: number, array: Uint8ClampedArray) => unknown, thisArg?: any): boolean; + some(/** @immediate */ predicate: (value: number, index: number, array: Uint8ClampedArray) => unknown, thisArg?: any): boolean; /** * Sorts an array. @@ -2635,7 +2635,7 @@ interface Uint8ClampedArray { * [11,2,22,1].sort((a, b) => a - b) * ``` */ - sort(compareFn?: (a: number, b: number) => number): this; + sort(/** @immediate */ comparefn?: (a: number, b: number) => number): this; /** * Gets a new Uint8ClampedArray view of the ArrayBuffer store for this array, referencing the elements @@ -2690,7 +2690,7 @@ interface Uint8ClampedArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Uint8ClampedArray; + from(arrayLike: ArrayLike, /** @immediate */ mapfn: (v: T, k: number) => number, thisArg?: any): Uint8ClampedArray; } declare var Uint8ClampedArray: Uint8ClampedArrayConstructor; @@ -2738,7 +2738,7 @@ interface Int16Array { * @param thisArg An object to which the this keyword can refer in the predicate function. * If thisArg is omitted, undefined is used as the this value. */ - every(predicate: (value: number, index: number, array: Int16Array) => unknown, thisArg?: any): boolean; + every(/** @immediate */ predicate: (value: number, index: number, array: Int16Array) => unknown, thisArg?: any): boolean; /** * Changes all array elements from `start` to `end` index to a static `value` and returns the modified array @@ -2757,7 +2757,7 @@ interface Int16Array { * @param thisArg An object to which the this keyword can refer in the predicate function. * If thisArg is omitted, undefined is used as the this value. */ - filter(predicate: (value: number, index: number, array: Int16Array) => any, thisArg?: any): Int16Array; + filter(/** @immediate */ predicate: (value: number, index: number, array: Int16Array) => any, thisArg?: any): Int16Array; /** * Returns the value of the first element in the array where predicate is true, and undefined @@ -2768,7 +2768,7 @@ interface Int16Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find(predicate: (value: number, index: number, obj: Int16Array) => boolean, thisArg?: any): number | undefined; + find(/** @immediate */ predicate: (value: number, index: number, obj: Int16Array) => boolean, thisArg?: any): number | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -2779,7 +2779,7 @@ interface Int16Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (value: number, index: number, obj: Int16Array) => boolean, thisArg?: any): number; + findIndex(/** @immediate */ predicate: (value: number, index: number, obj: Int16Array) => boolean, thisArg?: any): number; /** * Performs the specified action for each element in an array. @@ -2788,7 +2788,7 @@ interface Int16Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - forEach(callbackfn: (value: number, index: number, array: Int16Array) => void, thisArg?: any): void; + forEach(/** @immediate */ callbackfn: (value: number, index: number, array: Int16Array) => void, thisArg?: any): void; /** * Returns the index of the first occurrence of a value in an array. * @param searchElement The value to locate in the array. @@ -2825,7 +2825,7 @@ interface Int16Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - map(callbackfn: (value: number, index: number, array: Int16Array) => number, thisArg?: any): Int16Array; + map(/** @immediate */ callbackfn: (value: number, index: number, array: Int16Array) => number, thisArg?: any): Int16Array; /** * Calls the specified callback function for all the elements in an array. The return value of @@ -2837,8 +2837,8 @@ interface Int16Array { * the accumulation. The first call to the callbackfn function provides this value as an argument * instead of an array value. */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int16Array) => number): number; - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int16Array) => number, initialValue: number): number; + reduce(/** @immediate */ callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int16Array) => number): number; + reduce(/** @immediate */ callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int16Array) => number, initialValue: number): number; /** * Calls the specified callback function for all the elements in an array. The return value of @@ -2850,7 +2850,7 @@ interface Int16Array { * the accumulation. The first call to the callbackfn function provides this value as an argument * instead of an array value. */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int16Array) => U, initialValue: U): U; + reduce(/** @immediate */ callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int16Array) => U, initialValue: U): U; /** * Calls the specified callback function for all the elements in an array, in descending order. @@ -2862,8 +2862,8 @@ interface Int16Array { * the accumulation. The first call to the callbackfn function provides this value as an * argument instead of an array value. */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int16Array) => number): number; - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int16Array) => number, initialValue: number): number; + reduceRight(/** @immediate */ callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int16Array) => number): number; + reduceRight(/** @immediate */ callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int16Array) => number, initialValue: number): number; /** * Calls the specified callback function for all the elements in an array, in descending order. @@ -2875,7 +2875,7 @@ interface Int16Array { * the accumulation. The first call to the callbackfn function provides this value as an argument * instead of an array value. */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int16Array) => U, initialValue: U): U; + reduceRight(/** @immediate */ callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int16Array) => U, initialValue: U): U; /** * Reverses the elements in an Array. @@ -2904,7 +2904,7 @@ interface Int16Array { * @param thisArg An object to which the this keyword can refer in the predicate function. * If thisArg is omitted, undefined is used as the this value. */ - some(predicate: (value: number, index: number, array: Int16Array) => unknown, thisArg?: any): boolean; + some(/** @immediate */ predicate: (value: number, index: number, array: Int16Array) => unknown, thisArg?: any): boolean; /** * Sorts an array. @@ -2915,7 +2915,7 @@ interface Int16Array { * [11,2,22,1].sort((a, b) => a - b) * ``` */ - sort(compareFn?: (a: number, b: number) => number): this; + sort(/** @immediate */ comparefn?: (a: number, b: number) => number): this; /** * Gets a new Int16Array view of the ArrayBuffer store for this array, referencing the elements @@ -2970,7 +2970,7 @@ interface Int16ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Int16Array; + from(arrayLike: ArrayLike, /** @immediate */ mapfn: (v: T, k: number) => number, thisArg?: any): Int16Array; } declare var Int16Array: Int16ArrayConstructor; @@ -3018,7 +3018,7 @@ interface Uint16Array { * @param thisArg An object to which the this keyword can refer in the predicate function. * If thisArg is omitted, undefined is used as the this value. */ - every(predicate: (value: number, index: number, array: Uint16Array) => unknown, thisArg?: any): boolean; + every(/** @immediate */ predicate: (value: number, index: number, array: Uint16Array) => unknown, thisArg?: any): boolean; /** * Changes all array elements from `start` to `end` index to a static `value` and returns the modified array @@ -3037,7 +3037,7 @@ interface Uint16Array { * @param thisArg An object to which the this keyword can refer in the predicate function. * If thisArg is omitted, undefined is used as the this value. */ - filter(predicate: (value: number, index: number, array: Uint16Array) => any, thisArg?: any): Uint16Array; + filter(/** @immediate */ predicate: (value: number, index: number, array: Uint16Array) => any, thisArg?: any): Uint16Array; /** * Returns the value of the first element in the array where predicate is true, and undefined @@ -3048,7 +3048,7 @@ interface Uint16Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find(predicate: (value: number, index: number, obj: Uint16Array) => boolean, thisArg?: any): number | undefined; + find(/** @immediate */ predicate: (value: number, index: number, obj: Uint16Array) => boolean, thisArg?: any): number | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -3059,7 +3059,7 @@ interface Uint16Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (value: number, index: number, obj: Uint16Array) => boolean, thisArg?: any): number; + findIndex(/** @immediate */ predicate: (value: number, index: number, obj: Uint16Array) => boolean, thisArg?: any): number; /** * Performs the specified action for each element in an array. @@ -3068,7 +3068,7 @@ interface Uint16Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - forEach(callbackfn: (value: number, index: number, array: Uint16Array) => void, thisArg?: any): void; + forEach(/** @immediate */ callbackfn: (value: number, index: number, array: Uint16Array) => void, thisArg?: any): void; /** * Returns the index of the first occurrence of a value in an array. @@ -3106,7 +3106,7 @@ interface Uint16Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - map(callbackfn: (value: number, index: number, array: Uint16Array) => number, thisArg?: any): Uint16Array; + map(/** @immediate */ callbackfn: (value: number, index: number, array: Uint16Array) => number, thisArg?: any): Uint16Array; /** * Calls the specified callback function for all the elements in an array. The return value of @@ -3118,8 +3118,8 @@ interface Uint16Array { * the accumulation. The first call to the callbackfn function provides this value as an argument * instead of an array value. */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint16Array) => number): number; - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint16Array) => number, initialValue: number): number; + reduce(/** @immediate */ callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint16Array) => number): number; + reduce(/** @immediate */ callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint16Array) => number, initialValue: number): number; /** * Calls the specified callback function for all the elements in an array. The return value of @@ -3131,7 +3131,7 @@ interface Uint16Array { * the accumulation. The first call to the callbackfn function provides this value as an argument * instead of an array value. */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint16Array) => U, initialValue: U): U; + reduce(/** @immediate */ callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint16Array) => U, initialValue: U): U; /** * Calls the specified callback function for all the elements in an array, in descending order. @@ -3143,8 +3143,8 @@ interface Uint16Array { * the accumulation. The first call to the callbackfn function provides this value as an * argument instead of an array value. */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint16Array) => number): number; - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint16Array) => number, initialValue: number): number; + reduceRight(/** @immediate */ callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint16Array) => number): number; + reduceRight(/** @immediate */ callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint16Array) => number, initialValue: number): number; /** * Calls the specified callback function for all the elements in an array, in descending order. @@ -3156,7 +3156,7 @@ interface Uint16Array { * the accumulation. The first call to the callbackfn function provides this value as an argument * instead of an array value. */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint16Array) => U, initialValue: U): U; + reduceRight(/** @immediate */ callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint16Array) => U, initialValue: U): U; /** * Reverses the elements in an Array. @@ -3185,7 +3185,7 @@ interface Uint16Array { * @param thisArg An object to which the this keyword can refer in the predicate function. * If thisArg is omitted, undefined is used as the this value. */ - some(predicate: (value: number, index: number, array: Uint16Array) => unknown, thisArg?: any): boolean; + some(/** @immediate */ predicate: (value: number, index: number, array: Uint16Array) => unknown, thisArg?: any): boolean; /** * Sorts an array. @@ -3196,7 +3196,7 @@ interface Uint16Array { * [11,2,22,1].sort((a, b) => a - b) * ``` */ - sort(compareFn?: (a: number, b: number) => number): this; + sort(/** @immediate */ comparefn?: (a: number, b: number) => number): this; /** * Gets a new Uint16Array view of the ArrayBuffer store for this array, referencing the elements @@ -3251,7 +3251,7 @@ interface Uint16ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Uint16Array; + from(arrayLike: ArrayLike, /** @immediate */ mapfn: (v: T, k: number) => number, thisArg?: any): Uint16Array; } declare var Uint16Array: Uint16ArrayConstructor; /** @@ -3298,7 +3298,7 @@ interface Int32Array { * @param thisArg An object to which the this keyword can refer in the predicate function. * If thisArg is omitted, undefined is used as the this value. */ - every(predicate: (value: number, index: number, array: Int32Array) => unknown, thisArg?: any): boolean; + every(/** @immediate */ predicate: (value: number, index: number, array: Int32Array) => unknown, thisArg?: any): boolean; /** * Changes all array elements from `start` to `end` index to a static `value` and returns the modified array @@ -3317,7 +3317,7 @@ interface Int32Array { * @param thisArg An object to which the this keyword can refer in the predicate function. * If thisArg is omitted, undefined is used as the this value. */ - filter(predicate: (value: number, index: number, array: Int32Array) => any, thisArg?: any): Int32Array; + filter(/** @immediate */ predicate: (value: number, index: number, array: Int32Array) => any, thisArg?: any): Int32Array; /** * Returns the value of the first element in the array where predicate is true, and undefined @@ -3328,7 +3328,7 @@ interface Int32Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find(predicate: (value: number, index: number, obj: Int32Array) => boolean, thisArg?: any): number | undefined; + find(/** @immediate */ predicate: (value: number, index: number, obj: Int32Array) => boolean, thisArg?: any): number | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -3339,7 +3339,7 @@ interface Int32Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (value: number, index: number, obj: Int32Array) => boolean, thisArg?: any): number; + findIndex(/** @immediate */ predicate: (value: number, index: number, obj: Int32Array) => boolean, thisArg?: any): number; /** * Performs the specified action for each element in an array. @@ -3348,7 +3348,7 @@ interface Int32Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - forEach(callbackfn: (value: number, index: number, array: Int32Array) => void, thisArg?: any): void; + forEach(/** @immediate */ callbackfn: (value: number, index: number, array: Int32Array) => void, thisArg?: any): void; /** * Returns the index of the first occurrence of a value in an array. @@ -3386,7 +3386,7 @@ interface Int32Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - map(callbackfn: (value: number, index: number, array: Int32Array) => number, thisArg?: any): Int32Array; + map(/** @immediate */ callbackfn: (value: number, index: number, array: Int32Array) => number, thisArg?: any): Int32Array; /** * Calls the specified callback function for all the elements in an array. The return value of @@ -3398,8 +3398,8 @@ interface Int32Array { * the accumulation. The first call to the callbackfn function provides this value as an argument * instead of an array value. */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int32Array) => number): number; - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int32Array) => number, initialValue: number): number; + reduce(/** @immediate */ callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int32Array) => number): number; + reduce(/** @immediate */ callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int32Array) => number, initialValue: number): number; /** * Calls the specified callback function for all the elements in an array. The return value of @@ -3411,7 +3411,7 @@ interface Int32Array { * the accumulation. The first call to the callbackfn function provides this value as an argument * instead of an array value. */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int32Array) => U, initialValue: U): U; + reduce(/** @immediate */ callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int32Array) => U, initialValue: U): U; /** * Calls the specified callback function for all the elements in an array, in descending order. @@ -3423,8 +3423,8 @@ interface Int32Array { * the accumulation. The first call to the callbackfn function provides this value as an * argument instead of an array value. */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int32Array) => number): number; - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int32Array) => number, initialValue: number): number; + reduceRight(/** @immediate */ callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int32Array) => number): number; + reduceRight(/** @immediate */ callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int32Array) => number, initialValue: number): number; /** * Calls the specified callback function for all the elements in an array, in descending order. @@ -3436,7 +3436,7 @@ interface Int32Array { * the accumulation. The first call to the callbackfn function provides this value as an argument * instead of an array value. */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int32Array) => U, initialValue: U): U; + reduceRight(/** @immediate */ callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int32Array) => U, initialValue: U): U; /** * Reverses the elements in an Array. @@ -3465,7 +3465,7 @@ interface Int32Array { * @param thisArg An object to which the this keyword can refer in the predicate function. * If thisArg is omitted, undefined is used as the this value. */ - some(predicate: (value: number, index: number, array: Int32Array) => unknown, thisArg?: any): boolean; + some(/** @immediate */ predicate: (value: number, index: number, array: Int32Array) => unknown, thisArg?: any): boolean; /** * Sorts an array. @@ -3476,7 +3476,7 @@ interface Int32Array { * [11,2,22,1].sort((a, b) => a - b) * ``` */ - sort(compareFn?: (a: number, b: number) => number): this; + sort(/** @immediate */ comparefn?: (a: number, b: number) => number): this; /** * Gets a new Int32Array view of the ArrayBuffer store for this array, referencing the elements @@ -3531,7 +3531,7 @@ interface Int32ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Int32Array; + from(arrayLike: ArrayLike, /** @immediate */ mapfn: (v: T, k: number) => number, thisArg?: any): Int32Array; } declare var Int32Array: Int32ArrayConstructor; @@ -3579,7 +3579,7 @@ interface Uint32Array { * @param thisArg An object to which the this keyword can refer in the predicate function. * If thisArg is omitted, undefined is used as the this value. */ - every(predicate: (value: number, index: number, array: Uint32Array) => unknown, thisArg?: any): boolean; + every(/** @immediate */ predicate: (value: number, index: number, array: Uint32Array) => unknown, thisArg?: any): boolean; /** * Changes all array elements from `start` to `end` index to a static `value` and returns the modified array @@ -3598,7 +3598,7 @@ interface Uint32Array { * @param thisArg An object to which the this keyword can refer in the predicate function. * If thisArg is omitted, undefined is used as the this value. */ - filter(predicate: (value: number, index: number, array: Uint32Array) => any, thisArg?: any): Uint32Array; + filter(/** @immediate */ predicate: (value: number, index: number, array: Uint32Array) => any, thisArg?: any): Uint32Array; /** * Returns the value of the first element in the array where predicate is true, and undefined @@ -3609,7 +3609,7 @@ interface Uint32Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find(predicate: (value: number, index: number, obj: Uint32Array) => boolean, thisArg?: any): number | undefined; + find(/** @immediate */ predicate: (value: number, index: number, obj: Uint32Array) => boolean, thisArg?: any): number | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -3620,7 +3620,7 @@ interface Uint32Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (value: number, index: number, obj: Uint32Array) => boolean, thisArg?: any): number; + findIndex(/** @immediate */ predicate: (value: number, index: number, obj: Uint32Array) => boolean, thisArg?: any): number; /** * Performs the specified action for each element in an array. @@ -3629,7 +3629,7 @@ interface Uint32Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - forEach(callbackfn: (value: number, index: number, array: Uint32Array) => void, thisArg?: any): void; + forEach(/** @immediate */ callbackfn: (value: number, index: number, array: Uint32Array) => void, thisArg?: any): void; /** * Returns the index of the first occurrence of a value in an array. * @param searchElement The value to locate in the array. @@ -3666,7 +3666,7 @@ interface Uint32Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - map(callbackfn: (value: number, index: number, array: Uint32Array) => number, thisArg?: any): Uint32Array; + map(/** @immediate */ callbackfn: (value: number, index: number, array: Uint32Array) => number, thisArg?: any): Uint32Array; /** * Calls the specified callback function for all the elements in an array. The return value of @@ -3678,8 +3678,8 @@ interface Uint32Array { * the accumulation. The first call to the callbackfn function provides this value as an argument * instead of an array value. */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint32Array) => number): number; - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint32Array) => number, initialValue: number): number; + reduce(/** @immediate */ callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint32Array) => number): number; + reduce(/** @immediate */ callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint32Array) => number, initialValue: number): number; /** * Calls the specified callback function for all the elements in an array. The return value of @@ -3691,7 +3691,7 @@ interface Uint32Array { * the accumulation. The first call to the callbackfn function provides this value as an argument * instead of an array value. */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint32Array) => U, initialValue: U): U; + reduce(/** @immediate */ callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint32Array) => U, initialValue: U): U; /** * Calls the specified callback function for all the elements in an array, in descending order. @@ -3703,8 +3703,8 @@ interface Uint32Array { * the accumulation. The first call to the callbackfn function provides this value as an * argument instead of an array value. */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint32Array) => number): number; - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint32Array) => number, initialValue: number): number; + reduceRight(/** @immediate */ callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint32Array) => number): number; + reduceRight(/** @immediate */ callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint32Array) => number, initialValue: number): number; /** * Calls the specified callback function for all the elements in an array, in descending order. @@ -3716,7 +3716,7 @@ interface Uint32Array { * the accumulation. The first call to the callbackfn function provides this value as an argument * instead of an array value. */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint32Array) => U, initialValue: U): U; + reduceRight(/** @immediate */ callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint32Array) => U, initialValue: U): U; /** * Reverses the elements in an Array. @@ -3745,7 +3745,7 @@ interface Uint32Array { * @param thisArg An object to which the this keyword can refer in the predicate function. * If thisArg is omitted, undefined is used as the this value. */ - some(predicate: (value: number, index: number, array: Uint32Array) => unknown, thisArg?: any): boolean; + some(/** @immediate */ predicate: (value: number, index: number, array: Uint32Array) => unknown, thisArg?: any): boolean; /** * Sorts an array. @@ -3756,7 +3756,7 @@ interface Uint32Array { * [11,2,22,1].sort((a, b) => a - b) * ``` */ - sort(compareFn?: (a: number, b: number) => number): this; + sort(/** @immediate */ comparefn?: (a: number, b: number) => number): this; /** * Gets a new Uint32Array view of the ArrayBuffer store for this array, referencing the elements @@ -3811,7 +3811,7 @@ interface Uint32ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Uint32Array; + from(arrayLike: ArrayLike, /** @immediate */ mapfn: (v: T, k: number) => number, thisArg?: any): Uint32Array; } declare var Uint32Array: Uint32ArrayConstructor; @@ -3859,7 +3859,7 @@ interface Float32Array { * @param thisArg An object to which the this keyword can refer in the predicate function. * If thisArg is omitted, undefined is used as the this value. */ - every(predicate: (value: number, index: number, array: Float32Array) => unknown, thisArg?: any): boolean; + every(/** @immediate */ predicate: (value: number, index: number, array: Float32Array) => unknown, thisArg?: any): boolean; /** * Changes all array elements from `start` to `end` index to a static `value` and returns the modified array @@ -3878,7 +3878,7 @@ interface Float32Array { * @param thisArg An object to which the this keyword can refer in the predicate function. * If thisArg is omitted, undefined is used as the this value. */ - filter(predicate: (value: number, index: number, array: Float32Array) => any, thisArg?: any): Float32Array; + filter(/** @immediate */ predicate: (value: number, index: number, array: Float32Array) => any, thisArg?: any): Float32Array; /** * Returns the value of the first element in the array where predicate is true, and undefined @@ -3889,7 +3889,7 @@ interface Float32Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find(predicate: (value: number, index: number, obj: Float32Array) => boolean, thisArg?: any): number | undefined; + find(/** @immediate */ predicate: (value: number, index: number, obj: Float32Array) => boolean, thisArg?: any): number | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -3900,7 +3900,7 @@ interface Float32Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (value: number, index: number, obj: Float32Array) => boolean, thisArg?: any): number; + findIndex(/** @immediate */ predicate: (value: number, index: number, obj: Float32Array) => boolean, thisArg?: any): number; /** * Performs the specified action for each element in an array. @@ -3909,7 +3909,7 @@ interface Float32Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - forEach(callbackfn: (value: number, index: number, array: Float32Array) => void, thisArg?: any): void; + forEach(/** @immediate */ callbackfn: (value: number, index: number, array: Float32Array) => void, thisArg?: any): void; /** * Returns the index of the first occurrence of a value in an array. @@ -3947,7 +3947,7 @@ interface Float32Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - map(callbackfn: (value: number, index: number, array: Float32Array) => number, thisArg?: any): Float32Array; + map(/** @immediate */ callbackfn: (value: number, index: number, array: Float32Array) => number, thisArg?: any): Float32Array; /** * Calls the specified callback function for all the elements in an array. The return value of @@ -3959,8 +3959,8 @@ interface Float32Array { * the accumulation. The first call to the callbackfn function provides this value as an argument * instead of an array value. */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float32Array) => number): number; - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float32Array) => number, initialValue: number): number; + reduce(/** @immediate */ callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float32Array) => number): number; + reduce(/** @immediate */ callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float32Array) => number, initialValue: number): number; /** * Calls the specified callback function for all the elements in an array. The return value of @@ -3972,7 +3972,7 @@ interface Float32Array { * the accumulation. The first call to the callbackfn function provides this value as an argument * instead of an array value. */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float32Array) => U, initialValue: U): U; + reduce(/** @immediate */ callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float32Array) => U, initialValue: U): U; /** * Calls the specified callback function for all the elements in an array, in descending order. @@ -3984,8 +3984,8 @@ interface Float32Array { * the accumulation. The first call to the callbackfn function provides this value as an * argument instead of an array value. */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float32Array) => number): number; - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float32Array) => number, initialValue: number): number; + reduceRight(/** @immediate */ callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float32Array) => number): number; + reduceRight(/** @immediate */ callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float32Array) => number, initialValue: number): number; /** * Calls the specified callback function for all the elements in an array, in descending order. @@ -3997,7 +3997,7 @@ interface Float32Array { * the accumulation. The first call to the callbackfn function provides this value as an argument * instead of an array value. */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float32Array) => U, initialValue: U): U; + reduceRight(/** @immediate */ callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float32Array) => U, initialValue: U): U; /** * Reverses the elements in an Array. @@ -4026,7 +4026,7 @@ interface Float32Array { * @param thisArg An object to which the this keyword can refer in the predicate function. * If thisArg is omitted, undefined is used as the this value. */ - some(predicate: (value: number, index: number, array: Float32Array) => unknown, thisArg?: any): boolean; + some(/** @immediate */ predicate: (value: number, index: number, array: Float32Array) => unknown, thisArg?: any): boolean; /** * Sorts an array. @@ -4037,7 +4037,7 @@ interface Float32Array { * [11,2,22,1].sort((a, b) => a - b) * ``` */ - sort(compareFn?: (a: number, b: number) => number): this; + sort(/** @immediate */ comparefn?: (a: number, b: number) => number): this; /** * Gets a new Float32Array view of the ArrayBuffer store for this array, referencing the elements @@ -4092,7 +4092,7 @@ interface Float32ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Float32Array; + from(arrayLike: ArrayLike, /** @immediate */ mapfn: (v: T, k: number) => number, thisArg?: any): Float32Array; } declare var Float32Array: Float32ArrayConstructor; @@ -4140,7 +4140,7 @@ interface Float64Array { * @param thisArg An object to which the this keyword can refer in the predicate function. * If thisArg is omitted, undefined is used as the this value. */ - every(predicate: (value: number, index: number, array: Float64Array) => unknown, thisArg?: any): boolean; + every(/** @immediate */ predicate: (value: number, index: number, array: Float64Array) => unknown, thisArg?: any): boolean; /** * Changes all array elements from `start` to `end` index to a static `value` and returns the modified array @@ -4159,7 +4159,7 @@ interface Float64Array { * @param thisArg An object to which the this keyword can refer in the predicate function. * If thisArg is omitted, undefined is used as the this value. */ - filter(predicate: (value: number, index: number, array: Float64Array) => any, thisArg?: any): Float64Array; + filter(/** @immediate */ predicate: (value: number, index: number, array: Float64Array) => any, thisArg?: any): Float64Array; /** * Returns the value of the first element in the array where predicate is true, and undefined @@ -4170,7 +4170,7 @@ interface Float64Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find(predicate: (value: number, index: number, obj: Float64Array) => boolean, thisArg?: any): number | undefined; + find(/** @immediate */ predicate: (value: number, index: number, obj: Float64Array) => boolean, thisArg?: any): number | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -4181,7 +4181,7 @@ interface Float64Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (value: number, index: number, obj: Float64Array) => boolean, thisArg?: any): number; + findIndex(/** @immediate */ predicate: (value: number, index: number, obj: Float64Array) => boolean, thisArg?: any): number; /** * Performs the specified action for each element in an array. @@ -4190,7 +4190,7 @@ interface Float64Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - forEach(callbackfn: (value: number, index: number, array: Float64Array) => void, thisArg?: any): void; + forEach(/** @immediate */ callbackfn: (value: number, index: number, array: Float64Array) => void, thisArg?: any): void; /** * Returns the index of the first occurrence of a value in an array. @@ -4228,7 +4228,7 @@ interface Float64Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - map(callbackfn: (value: number, index: number, array: Float64Array) => number, thisArg?: any): Float64Array; + map(/** @immediate */ callbackfn: (value: number, index: number, array: Float64Array) => number, thisArg?: any): Float64Array; /** * Calls the specified callback function for all the elements in an array. The return value of @@ -4240,8 +4240,8 @@ interface Float64Array { * the accumulation. The first call to the callbackfn function provides this value as an argument * instead of an array value. */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float64Array) => number): number; - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float64Array) => number, initialValue: number): number; + reduce(/** @immediate */ callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float64Array) => number): number; + reduce(/** @immediate */ callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float64Array) => number, initialValue: number): number; /** * Calls the specified callback function for all the elements in an array. The return value of @@ -4253,7 +4253,7 @@ interface Float64Array { * the accumulation. The first call to the callbackfn function provides this value as an argument * instead of an array value. */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float64Array) => U, initialValue: U): U; + reduce(/** @immediate */ callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float64Array) => U, initialValue: U): U; /** * Calls the specified callback function for all the elements in an array, in descending order. @@ -4265,8 +4265,8 @@ interface Float64Array { * the accumulation. The first call to the callbackfn function provides this value as an * argument instead of an array value. */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float64Array) => number): number; - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float64Array) => number, initialValue: number): number; + reduceRight(/** @immediate */ callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float64Array) => number): number; + reduceRight(/** @immediate */ callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float64Array) => number, initialValue: number): number; /** * Calls the specified callback function for all the elements in an array, in descending order. @@ -4278,7 +4278,7 @@ interface Float64Array { * the accumulation. The first call to the callbackfn function provides this value as an argument * instead of an array value. */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float64Array) => U, initialValue: U): U; + reduceRight(/** @immediate */ callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float64Array) => U, initialValue: U): U; /** * Reverses the elements in an Array. @@ -4307,7 +4307,7 @@ interface Float64Array { * @param thisArg An object to which the this keyword can refer in the predicate function. * If thisArg is omitted, undefined is used as the this value. */ - some(predicate: (value: number, index: number, array: Float64Array) => unknown, thisArg?: any): boolean; + some(/** @immediate */ predicate: (value: number, index: number, array: Float64Array) => unknown, thisArg?: any): boolean; /** * Sorts an array. @@ -4318,7 +4318,7 @@ interface Float64Array { * [11,2,22,1].sort((a, b) => a - b) * ``` */ - sort(compareFn?: (a: number, b: number) => number): this; + sort(/** @immediate */ comparefn?: (a: number, b: number) => number): this; /** * Gets a new Float64Array view of the ArrayBuffer store for this array, referencing the elements @@ -4373,7 +4373,7 @@ interface Float64ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Float64Array; + from(arrayLike: ArrayLike, /** @immediate */ mapfn: (v: T, k: number) => number, thisArg?: any): Float64Array; } declare var Float64Array: Float64ArrayConstructor; diff --git a/src/lib/esnext.array.d.ts b/src/lib/esnext.array.d.ts index 6842e5d0c401a..1afbf34fd0b96 100644 --- a/src/lib/esnext.array.d.ts +++ b/src/lib/esnext.array.d.ts @@ -13,5 +13,5 @@ interface ArrayConstructor { * Each return value is awaited before being added to result array. * @param thisArg Value of 'this' used when executing mapfn. */ - fromAsync(iterableOrArrayLike: AsyncIterable | Iterable | ArrayLike, mapFn: (value: Awaited) => U, thisArg?: any): Promise[]>; + fromAsync(iterableOrArrayLike: AsyncIterable | Iterable | ArrayLike, /** @immediate */ mapFn: (value: Awaited) => U, thisArg?: any): Promise[]>; } diff --git a/src/lib/esnext.collection.d.ts b/src/lib/esnext.collection.d.ts index 504ed6782d4bb..207a1bbdf03b9 100644 --- a/src/lib/esnext.collection.d.ts +++ b/src/lib/esnext.collection.d.ts @@ -6,7 +6,7 @@ interface MapConstructor { */ groupBy( items: Iterable, - keySelector: (item: T, index: number) => K, + /** @immediate */ keySelector: (item: T, index: number) => K, ): Map; } diff --git a/src/lib/esnext.iterator.d.ts b/src/lib/esnext.iterator.d.ts index fe929f59c2206..cb97030941410 100644 --- a/src/lib/esnext.iterator.d.ts +++ b/src/lib/esnext.iterator.d.ts @@ -29,19 +29,19 @@ declare global { * Creates an iterator whose values are the result of applying the callback to the values from this iterator. * @param callbackfn A function that accepts up to two arguments to be used to transform values from the underlying iterator. */ - map(callbackfn: (value: T, index: number) => U): IteratorObject; + map(/** @immediate */ callbackfn: (value: T, index: number) => U): IteratorObject; /** * Creates an iterator whose values are those from this iterator for which the provided predicate returns true. * @param predicate A function that accepts up to two arguments to be used to test values from the underlying iterator. */ - filter(predicate: (value: T, index: number) => value is S): IteratorObject; + filter(/** @immediate */ predicate: (value: T, index: number) => value is S): IteratorObject; /** * Creates an iterator whose values are those from this iterator for which the provided predicate returns true. * @param predicate A function that accepts up to two arguments to be used to test values from the underlying iterator. */ - filter(predicate: (value: T, index: number) => unknown): IteratorObject; + filter(/** @immediate */ predicate: (value: T, index: number) => unknown): IteratorObject; /** * Creates an iterator whose values are the values from this iterator, stopping once the provided limit is reached. @@ -59,22 +59,22 @@ declare global { * Creates an iterator whose values are the result of applying the callback to the values from this iterator and then flattening the resulting iterators or iterables. * @param callback A function that accepts up to two arguments to be used to transform values from the underlying iterator into new iterators or iterables to be flattened into the result. */ - flatMap(callback: (value: T, index: number) => Iterator | Iterable): IteratorObject; + flatMap(/** @immediate */ callback: (value: T, index: number) => Iterator | Iterable): IteratorObject; /** * Calls the specified callback function for all the elements in this iterator. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. * @param callbackfn A function that accepts up to three arguments. The reduce method calls the callbackfn function one time for each element in the iterator. * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of a value from the iterator. */ - reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number) => T): T; - reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number) => T, initialValue: T): T; + reduce(/** @immediate */ callbackfn: (previousValue: T, currentValue: T, currentIndex: number) => T): T; + reduce(/** @immediate */ callbackfn: (previousValue: T, currentValue: T, currentIndex: number) => T, initialValue: T): T; /** * Calls the specified callback function for all the elements in this iterator. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. * @param callbackfn A function that accepts up to three arguments. The reduce method calls the callbackfn function one time for each element in the iterator. * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of a value from the iterator. */ - reduce(callbackfn: (previousValue: U, currentValue: T, currentIndex: number) => U, initialValue: U): U; + reduce(/** @immediate */ callbackfn: (previousValue: U, currentValue: T, currentIndex: number) => U, initialValue: U): U; /** * Creates a new array from the values yielded by this iterator. @@ -85,7 +85,7 @@ declare global { * Performs the specified action for each element in the iterator. * @param callbackfn A function that accepts up to two arguments. forEach calls the callbackfn function one time for each element in the iterator. */ - forEach(callbackfn: (value: T, index: number) => void): void; + forEach(/** @immediate */ callbackfn: (value: T, index: number) => void): void; /** * Determines whether the specified callback function returns true for any element of this iterator. @@ -93,7 +93,7 @@ declare global { * the predicate function for each element in this iterator until the predicate returns a value * true, or until the end of the iterator. */ - some(predicate: (value: T, index: number) => unknown): boolean; + some(/** @immediate */ predicate: (value: T, index: number) => unknown): boolean; /** * Determines whether all the members of this iterator satisfy the specified test. @@ -101,7 +101,7 @@ declare global { * the predicate function for each element in this iterator until the predicate returns * false, or until the end of this iterator. */ - every(predicate: (value: T, index: number) => unknown): boolean; + every(/** @immediate */ predicate: (value: T, index: number) => unknown): boolean; /** * Returns the value of the first element in this iterator where predicate is true, and undefined @@ -110,8 +110,8 @@ declare global { * order, until it finds one where predicate returns true. If such an element is found, find * immediately returns that element value. Otherwise, find returns undefined. */ - find(predicate: (value: T, index: number) => value is S): S | undefined; - find(predicate: (value: T, index: number) => unknown): T | undefined; + find(/** @immediate */ predicate: (value: T, index: number) => value is S): S | undefined; + find(/** @immediate */ predicate: (value: T, index: number) => unknown): T | undefined; readonly [Symbol.toStringTag]: string; } diff --git a/src/lib/esnext.object.d.ts b/src/lib/esnext.object.d.ts index 0486ac078139c..28986ea8f2eb3 100644 --- a/src/lib/esnext.object.d.ts +++ b/src/lib/esnext.object.d.ts @@ -6,6 +6,6 @@ interface ObjectConstructor { */ groupBy( items: Iterable, - keySelector: (item: T, index: number) => K, + /** @immediate */ keySelector: (item: T, index: number) => K, ): Partial>; } diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index 0e82d5ba67891..6cf611df37e0a 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -3764,228 +3764,230 @@ declare namespace ts { ConstructorKeyword = 137, DeclareKeyword = 138, GetKeyword = 139, - InferKeyword = 140, - IntrinsicKeyword = 141, - IsKeyword = 142, - KeyOfKeyword = 143, - ModuleKeyword = 144, - NamespaceKeyword = 145, - NeverKeyword = 146, - OutKeyword = 147, - ReadonlyKeyword = 148, - RequireKeyword = 149, - NumberKeyword = 150, - ObjectKeyword = 151, - SatisfiesKeyword = 152, - SetKeyword = 153, - StringKeyword = 154, - SymbolKeyword = 155, - TypeKeyword = 156, - UndefinedKeyword = 157, - UniqueKeyword = 158, - UnknownKeyword = 159, - UsingKeyword = 160, - FromKeyword = 161, - GlobalKeyword = 162, - BigIntKeyword = 163, - OverrideKeyword = 164, - OfKeyword = 165, - QualifiedName = 166, - ComputedPropertyName = 167, - TypeParameter = 168, - Parameter = 169, - Decorator = 170, - PropertySignature = 171, - PropertyDeclaration = 172, - MethodSignature = 173, - MethodDeclaration = 174, - ClassStaticBlockDeclaration = 175, - Constructor = 176, - GetAccessor = 177, - SetAccessor = 178, - CallSignature = 179, - ConstructSignature = 180, - IndexSignature = 181, - TypePredicate = 182, - TypeReference = 183, - FunctionType = 184, - ConstructorType = 185, - TypeQuery = 186, - TypeLiteral = 187, - ArrayType = 188, - TupleType = 189, - OptionalType = 190, - RestType = 191, - UnionType = 192, - IntersectionType = 193, - ConditionalType = 194, - InferType = 195, - ParenthesizedType = 196, - ThisType = 197, - TypeOperator = 198, - IndexedAccessType = 199, - MappedType = 200, - LiteralType = 201, - NamedTupleMember = 202, - TemplateLiteralType = 203, - TemplateLiteralTypeSpan = 204, - ImportType = 205, - ObjectBindingPattern = 206, - ArrayBindingPattern = 207, - BindingElement = 208, - ArrayLiteralExpression = 209, - ObjectLiteralExpression = 210, - PropertyAccessExpression = 211, - ElementAccessExpression = 212, - CallExpression = 213, - NewExpression = 214, - TaggedTemplateExpression = 215, - TypeAssertionExpression = 216, - ParenthesizedExpression = 217, - FunctionExpression = 218, - ArrowFunction = 219, - DeleteExpression = 220, - TypeOfExpression = 221, - VoidExpression = 222, - AwaitExpression = 223, - PrefixUnaryExpression = 224, - PostfixUnaryExpression = 225, - BinaryExpression = 226, - ConditionalExpression = 227, - TemplateExpression = 228, - YieldExpression = 229, - SpreadElement = 230, - ClassExpression = 231, - OmittedExpression = 232, - ExpressionWithTypeArguments = 233, - AsExpression = 234, - NonNullExpression = 235, - MetaProperty = 236, - SyntheticExpression = 237, - SatisfiesExpression = 238, - TemplateSpan = 239, - SemicolonClassElement = 240, - Block = 241, - EmptyStatement = 242, - VariableStatement = 243, - ExpressionStatement = 244, - IfStatement = 245, - DoStatement = 246, - WhileStatement = 247, - ForStatement = 248, - ForInStatement = 249, - ForOfStatement = 250, - ContinueStatement = 251, - BreakStatement = 252, - ReturnStatement = 253, - WithStatement = 254, - SwitchStatement = 255, - LabeledStatement = 256, - ThrowStatement = 257, - TryStatement = 258, - DebuggerStatement = 259, - VariableDeclaration = 260, - VariableDeclarationList = 261, - FunctionDeclaration = 262, - ClassDeclaration = 263, - InterfaceDeclaration = 264, - TypeAliasDeclaration = 265, - EnumDeclaration = 266, - ModuleDeclaration = 267, - ModuleBlock = 268, - CaseBlock = 269, - NamespaceExportDeclaration = 270, - ImportEqualsDeclaration = 271, - ImportDeclaration = 272, - ImportClause = 273, - NamespaceImport = 274, - NamedImports = 275, - ImportSpecifier = 276, - ExportAssignment = 277, - ExportDeclaration = 278, - NamedExports = 279, - NamespaceExport = 280, - ExportSpecifier = 281, - MissingDeclaration = 282, - ExternalModuleReference = 283, - JsxElement = 284, - JsxSelfClosingElement = 285, - JsxOpeningElement = 286, - JsxClosingElement = 287, - JsxFragment = 288, - JsxOpeningFragment = 289, - JsxClosingFragment = 290, - JsxAttribute = 291, - JsxAttributes = 292, - JsxSpreadAttribute = 293, - JsxExpression = 294, - JsxNamespacedName = 295, - CaseClause = 296, - DefaultClause = 297, - HeritageClause = 298, - CatchClause = 299, - ImportAttributes = 300, - ImportAttribute = 301, - /** @deprecated */ AssertClause = 300, - /** @deprecated */ AssertEntry = 301, - /** @deprecated */ ImportTypeAssertionContainer = 302, - PropertyAssignment = 303, - ShorthandPropertyAssignment = 304, - SpreadAssignment = 305, - EnumMember = 306, - SourceFile = 307, - Bundle = 308, - JSDocTypeExpression = 309, - JSDocNameReference = 310, - JSDocMemberName = 311, - JSDocAllType = 312, - JSDocUnknownType = 313, - JSDocNullableType = 314, - JSDocNonNullableType = 315, - JSDocOptionalType = 316, - JSDocFunctionType = 317, - JSDocVariadicType = 318, - JSDocNamepathType = 319, - JSDoc = 320, + ImmediateKeyword = 140, + InferKeyword = 141, + IntrinsicKeyword = 142, + IsKeyword = 143, + KeyOfKeyword = 144, + ModuleKeyword = 145, + NamespaceKeyword = 146, + NeverKeyword = 147, + OutKeyword = 148, + ReadonlyKeyword = 149, + RequireKeyword = 150, + NumberKeyword = 151, + ObjectKeyword = 152, + SatisfiesKeyword = 153, + SetKeyword = 154, + StringKeyword = 155, + SymbolKeyword = 156, + TypeKeyword = 157, + UndefinedKeyword = 158, + UniqueKeyword = 159, + UnknownKeyword = 160, + UsingKeyword = 161, + FromKeyword = 162, + GlobalKeyword = 163, + BigIntKeyword = 164, + OverrideKeyword = 165, + OfKeyword = 166, + QualifiedName = 167, + ComputedPropertyName = 168, + TypeParameter = 169, + Parameter = 170, + Decorator = 171, + PropertySignature = 172, + PropertyDeclaration = 173, + MethodSignature = 174, + MethodDeclaration = 175, + ClassStaticBlockDeclaration = 176, + Constructor = 177, + GetAccessor = 178, + SetAccessor = 179, + CallSignature = 180, + ConstructSignature = 181, + IndexSignature = 182, + TypePredicate = 183, + TypeReference = 184, + FunctionType = 185, + ConstructorType = 186, + TypeQuery = 187, + TypeLiteral = 188, + ArrayType = 189, + TupleType = 190, + OptionalType = 191, + RestType = 192, + UnionType = 193, + IntersectionType = 194, + ConditionalType = 195, + InferType = 196, + ParenthesizedType = 197, + ThisType = 198, + TypeOperator = 199, + IndexedAccessType = 200, + MappedType = 201, + LiteralType = 202, + NamedTupleMember = 203, + TemplateLiteralType = 204, + TemplateLiteralTypeSpan = 205, + ImportType = 206, + ObjectBindingPattern = 207, + ArrayBindingPattern = 208, + BindingElement = 209, + ArrayLiteralExpression = 210, + ObjectLiteralExpression = 211, + PropertyAccessExpression = 212, + ElementAccessExpression = 213, + CallExpression = 214, + NewExpression = 215, + TaggedTemplateExpression = 216, + TypeAssertionExpression = 217, + ParenthesizedExpression = 218, + FunctionExpression = 219, + ArrowFunction = 220, + DeleteExpression = 221, + TypeOfExpression = 222, + VoidExpression = 223, + AwaitExpression = 224, + PrefixUnaryExpression = 225, + PostfixUnaryExpression = 226, + BinaryExpression = 227, + ConditionalExpression = 228, + TemplateExpression = 229, + YieldExpression = 230, + SpreadElement = 231, + ClassExpression = 232, + OmittedExpression = 233, + ExpressionWithTypeArguments = 234, + AsExpression = 235, + NonNullExpression = 236, + MetaProperty = 237, + SyntheticExpression = 238, + SatisfiesExpression = 239, + TemplateSpan = 240, + SemicolonClassElement = 241, + Block = 242, + EmptyStatement = 243, + VariableStatement = 244, + ExpressionStatement = 245, + IfStatement = 246, + DoStatement = 247, + WhileStatement = 248, + ForStatement = 249, + ForInStatement = 250, + ForOfStatement = 251, + ContinueStatement = 252, + BreakStatement = 253, + ReturnStatement = 254, + WithStatement = 255, + SwitchStatement = 256, + LabeledStatement = 257, + ThrowStatement = 258, + TryStatement = 259, + DebuggerStatement = 260, + VariableDeclaration = 261, + VariableDeclarationList = 262, + FunctionDeclaration = 263, + ClassDeclaration = 264, + InterfaceDeclaration = 265, + TypeAliasDeclaration = 266, + EnumDeclaration = 267, + ModuleDeclaration = 268, + ModuleBlock = 269, + CaseBlock = 270, + NamespaceExportDeclaration = 271, + ImportEqualsDeclaration = 272, + ImportDeclaration = 273, + ImportClause = 274, + NamespaceImport = 275, + NamedImports = 276, + ImportSpecifier = 277, + ExportAssignment = 278, + ExportDeclaration = 279, + NamedExports = 280, + NamespaceExport = 281, + ExportSpecifier = 282, + MissingDeclaration = 283, + ExternalModuleReference = 284, + JsxElement = 285, + JsxSelfClosingElement = 286, + JsxOpeningElement = 287, + JsxClosingElement = 288, + JsxFragment = 289, + JsxOpeningFragment = 290, + JsxClosingFragment = 291, + JsxAttribute = 292, + JsxAttributes = 293, + JsxSpreadAttribute = 294, + JsxExpression = 295, + JsxNamespacedName = 296, + CaseClause = 297, + DefaultClause = 298, + HeritageClause = 299, + CatchClause = 300, + ImportAttributes = 301, + ImportAttribute = 302, + /** @deprecated */ AssertClause = 301, + /** @deprecated */ AssertEntry = 302, + /** @deprecated */ ImportTypeAssertionContainer = 303, + PropertyAssignment = 304, + ShorthandPropertyAssignment = 305, + SpreadAssignment = 306, + EnumMember = 307, + SourceFile = 308, + Bundle = 309, + JSDocTypeExpression = 310, + JSDocNameReference = 311, + JSDocMemberName = 312, + JSDocAllType = 313, + JSDocUnknownType = 314, + JSDocNullableType = 315, + JSDocNonNullableType = 316, + JSDocOptionalType = 317, + JSDocFunctionType = 318, + JSDocVariadicType = 319, + JSDocNamepathType = 320, + JSDoc = 321, /** @deprecated Use SyntaxKind.JSDoc */ - JSDocComment = 320, - JSDocText = 321, - JSDocTypeLiteral = 322, - JSDocSignature = 323, - JSDocLink = 324, - JSDocLinkCode = 325, - JSDocLinkPlain = 326, - JSDocTag = 327, - JSDocAugmentsTag = 328, - JSDocImplementsTag = 329, - JSDocAuthorTag = 330, - JSDocDeprecatedTag = 331, - JSDocClassTag = 332, - JSDocPublicTag = 333, - JSDocPrivateTag = 334, - JSDocProtectedTag = 335, - JSDocReadonlyTag = 336, - JSDocOverrideTag = 337, - JSDocCallbackTag = 338, - JSDocOverloadTag = 339, - JSDocEnumTag = 340, - JSDocParameterTag = 341, - JSDocReturnTag = 342, - JSDocThisTag = 343, - JSDocTypeTag = 344, - JSDocTemplateTag = 345, - JSDocTypedefTag = 346, - JSDocSeeTag = 347, - JSDocPropertyTag = 348, - JSDocThrowsTag = 349, - JSDocSatisfiesTag = 350, - JSDocImportTag = 351, - SyntaxList = 352, - NotEmittedStatement = 353, - PartiallyEmittedExpression = 354, - CommaListExpression = 355, - SyntheticReferenceExpression = 356, - Count = 357, + JSDocComment = 321, + JSDocText = 322, + JSDocTypeLiteral = 323, + JSDocSignature = 324, + JSDocLink = 325, + JSDocLinkCode = 326, + JSDocLinkPlain = 327, + JSDocTag = 328, + JSDocAugmentsTag = 329, + JSDocImplementsTag = 330, + JSDocAuthorTag = 331, + JSDocDeprecatedTag = 332, + JSDocImmediateTag = 333, + JSDocClassTag = 334, + JSDocPublicTag = 335, + JSDocPrivateTag = 336, + JSDocProtectedTag = 337, + JSDocReadonlyTag = 338, + JSDocOverrideTag = 339, + JSDocCallbackTag = 340, + JSDocOverloadTag = 341, + JSDocEnumTag = 342, + JSDocParameterTag = 343, + JSDocReturnTag = 344, + JSDocThisTag = 345, + JSDocTypeTag = 346, + JSDocTemplateTag = 347, + JSDocTypedefTag = 348, + JSDocSeeTag = 349, + JSDocPropertyTag = 350, + JSDocThrowsTag = 351, + JSDocSatisfiesTag = 352, + JSDocImportTag = 353, + SyntaxList = 354, + NotEmittedStatement = 355, + PartiallyEmittedExpression = 356, + CommaListExpression = 357, + SyntheticReferenceExpression = 358, + Count = 359, FirstAssignment = 64, LastAssignment = 79, FirstCompoundAssignment = 65, @@ -3993,15 +3995,15 @@ declare namespace ts { FirstReservedWord = 83, LastReservedWord = 118, FirstKeyword = 83, - LastKeyword = 165, + LastKeyword = 166, FirstFutureReservedWord = 119, LastFutureReservedWord = 127, - FirstTypeNode = 182, - LastTypeNode = 205, + FirstTypeNode = 183, + LastTypeNode = 206, FirstPunctuation = 19, LastPunctuation = 79, FirstToken = 0, - LastToken = 165, + LastToken = 166, FirstTriviaToken = 2, LastTriviaToken = 7, FirstLiteralToken = 9, @@ -4010,13 +4012,13 @@ declare namespace ts { LastTemplateToken = 18, FirstBinaryOperator = 30, LastBinaryOperator = 79, - FirstStatement = 243, - LastStatement = 259, - FirstNode = 166, - FirstJSDocNode = 309, - LastJSDocNode = 351, - FirstJSDocTagNode = 327, - LastJSDocTagNode = 351, + FirstStatement = 244, + LastStatement = 260, + FirstNode = 167, + FirstJSDocNode = 310, + LastJSDocNode = 353, + FirstJSDocTagNode = 328, + LastJSDocTagNode = 353, } type TriviaSyntaxKind = SyntaxKind.SingleLineCommentTrivia | SyntaxKind.MultiLineCommentTrivia | SyntaxKind.NewLineTrivia | SyntaxKind.WhitespaceTrivia | SyntaxKind.ShebangTrivia | SyntaxKind.ConflictMarkerTrivia; type LiteralSyntaxKind = SyntaxKind.NumericLiteral | SyntaxKind.BigIntLiteral | SyntaxKind.StringLiteral | SyntaxKind.JsxText | SyntaxKind.JsxTextAllWhiteSpaces | SyntaxKind.RegularExpressionLiteral | SyntaxKind.NoSubstitutionTemplateLiteral; @@ -4118,6 +4120,7 @@ declare namespace ts { | SyntaxKind.GetKeyword | SyntaxKind.GlobalKeyword | SyntaxKind.IfKeyword + | SyntaxKind.ImmediateKeyword | SyntaxKind.ImplementsKeyword | SyntaxKind.ImportKeyword | SyntaxKind.InferKeyword @@ -4167,7 +4170,7 @@ declare namespace ts { | SyntaxKind.WhileKeyword | SyntaxKind.WithKeyword | SyntaxKind.YieldKeyword; - type ModifierSyntaxKind = SyntaxKind.AbstractKeyword | SyntaxKind.AccessorKeyword | SyntaxKind.AsyncKeyword | SyntaxKind.ConstKeyword | SyntaxKind.DeclareKeyword | SyntaxKind.DefaultKeyword | SyntaxKind.ExportKeyword | SyntaxKind.InKeyword | SyntaxKind.PrivateKeyword | SyntaxKind.ProtectedKeyword | SyntaxKind.PublicKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.OutKeyword | SyntaxKind.OverrideKeyword | SyntaxKind.StaticKeyword; + type ModifierSyntaxKind = SyntaxKind.AbstractKeyword | SyntaxKind.AccessorKeyword | SyntaxKind.AsyncKeyword | SyntaxKind.ConstKeyword | SyntaxKind.DeclareKeyword | SyntaxKind.DefaultKeyword | SyntaxKind.ExportKeyword | SyntaxKind.ImmediateKeyword | SyntaxKind.InKeyword | SyntaxKind.PrivateKeyword | SyntaxKind.ProtectedKeyword | SyntaxKind.PublicKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.OutKeyword | SyntaxKind.OverrideKeyword | SyntaxKind.StaticKeyword; type KeywordTypeSyntaxKind = SyntaxKind.AnyKeyword | SyntaxKind.BigIntKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.IntrinsicKeyword | SyntaxKind.NeverKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.StringKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.UndefinedKeyword | SyntaxKind.UnknownKeyword | SyntaxKind.VoidKeyword; type TokenSyntaxKind = SyntaxKind.Unknown | SyntaxKind.EndOfFileToken | TriviaSyntaxKind | LiteralSyntaxKind | PseudoLiteralSyntaxKind | PunctuationSyntaxKind | SyntaxKind.Identifier | KeywordSyntaxKind; type JsxTokenSyntaxKind = SyntaxKind.LessThanSlashToken | SyntaxKind.EndOfFileToken | SyntaxKind.ConflictMarkerTrivia | SyntaxKind.JsxText | SyntaxKind.JsxTextAllWhiteSpaces | SyntaxKind.OpenBraceToken | SyntaxKind.LessThanToken; @@ -4224,16 +4227,18 @@ declare namespace ts { In = 8192, Out = 16384, Decorator = 32768, - Deprecated = 65536, + Immediate = 65536, + Deprecated = 131072, + JSDocImmediate = 262144, HasComputedJSDocModifiers = 268435456, HasComputedFlags = 536870912, AccessibilityModifier = 7, ParameterPropertyModifier = 31, NonPublicAccessibilityModifier = 6, - TypeScriptModifier = 28895, + TypeScriptModifier = 94431, ExportDefault = 2080, - All = 131071, - Modifier = 98303, + All = 262143, + Modifier = 229375, } enum JsxFlags { None = 0, @@ -4383,6 +4388,7 @@ declare namespace ts { type DeclareKeyword = ModifierToken; type DefaultKeyword = ModifierToken; type ExportKeyword = ModifierToken; + type ImmediateKeyword = ModifierToken; type InKeyword = ModifierToken; type PrivateKeyword = ModifierToken; type ProtectedKeyword = ModifierToken; @@ -4391,7 +4397,7 @@ declare namespace ts { type OutKeyword = ModifierToken; type OverrideKeyword = ModifierToken; type StaticKeyword = ModifierToken; - type Modifier = AbstractKeyword | AccessorKeyword | AsyncKeyword | ConstKeyword | DeclareKeyword | DefaultKeyword | ExportKeyword | InKeyword | PrivateKeyword | ProtectedKeyword | PublicKeyword | OutKeyword | OverrideKeyword | ReadonlyKeyword | StaticKeyword; + type Modifier = AbstractKeyword | AccessorKeyword | AsyncKeyword | ConstKeyword | DeclareKeyword | DefaultKeyword | ExportKeyword | ImmediateKeyword | InKeyword | PrivateKeyword | ProtectedKeyword | PublicKeyword | OutKeyword | OverrideKeyword | ReadonlyKeyword | StaticKeyword; type ModifierLike = Modifier | Decorator; type AccessibilityModifier = PublicKeyword | PrivateKeyword | ProtectedKeyword; type ParameterPropertyModifier = AccessibilityModifier | ReadonlyKeyword; @@ -5721,6 +5727,9 @@ declare namespace ts { interface JSDocDeprecatedTag extends JSDocTag { kind: SyntaxKind.JSDocDeprecatedTag; } + interface JSDocImmediateTag extends JSDocTag { + kind: SyntaxKind.JSDocImmediateTag; + } interface JSDocClassTag extends JSDocTag { readonly kind: SyntaxKind.JSDocClassTag; } @@ -7736,6 +7745,8 @@ declare namespace ts { updateJSDocUnknownTag(node: JSDocUnknownTag, tagName: Identifier, comment: string | NodeArray | undefined): JSDocUnknownTag; createJSDocDeprecatedTag(tagName: Identifier | undefined, comment?: string | NodeArray): JSDocDeprecatedTag; updateJSDocDeprecatedTag(node: JSDocDeprecatedTag, tagName: Identifier | undefined, comment?: string | NodeArray): JSDocDeprecatedTag; + createJSDocImmediateTag(tagName: Identifier | undefined, comment?: string | NodeArray): JSDocImmediateTag; + updateJSDocImmediateTag(node: JSDocImmediateTag, tagName: Identifier | undefined, comment?: string | NodeArray): JSDocImmediateTag; createJSDocOverrideTag(tagName: Identifier | undefined, comment?: string | NodeArray): JSDocOverrideTag; updateJSDocOverrideTag(node: JSDocOverrideTag, tagName: Identifier | undefined, comment?: string | NodeArray): JSDocOverrideTag; createJSDocThrowsTag(tagName: Identifier, typeExpression: JSDocTypeExpression | undefined, comment?: string | NodeArray): JSDocThrowsTag; @@ -8589,6 +8600,8 @@ declare namespace ts { function getJSDocOverrideTagNoCache(node: Node): JSDocOverrideTag | undefined; /** Gets the JSDoc deprecated tag for the node if present */ function getJSDocDeprecatedTag(node: Node): JSDocDeprecatedTag | undefined; + /** Gets the JSDoc immediate tag for the node if present */ + function getJSDocImmediateTag(node: Node): JSDocImmediateTag | undefined; /** Gets the JSDoc enum tag for the node if present */ function getJSDocEnumTag(node: Node): JSDocEnumTag | undefined; /** Gets the JSDoc this tag for the node if present */ @@ -9033,6 +9046,7 @@ declare namespace ts { function isJSDocOverrideTag(node: Node): node is JSDocOverrideTag; function isJSDocOverloadTag(node: Node): node is JSDocOverloadTag; function isJSDocDeprecatedTag(node: Node): node is JSDocDeprecatedTag; + function isJSDocImmediateTag(node: Node): node is JSDocImmediateTag; function isJSDocSeeTag(node: Node): node is JSDocSeeTag; function isJSDocEnumTag(node: Node): node is JSDocEnumTag; function isJSDocParameterTag(node: Node): node is JSDocParameterTag; diff --git a/tests/baselines/reference/goToTypeDefinition_arrayType.baseline.jsonc b/tests/baselines/reference/goToTypeDefinition_arrayType.baseline.jsonc index 1dc5b63951e85..aea831a5590d4 100644 --- a/tests/baselines/reference/goToTypeDefinition_arrayType.baseline.jsonc +++ b/tests/baselines/reference/goToTypeDefinition_arrayType.baseline.jsonc @@ -83,7 +83,7 @@ // * [11,2,22,1].sort((a, b) => a - b) // * ``` // */ -// sort(compareFn?: (a: T, b: T) => number): this; +// sort(/** @immediate */ compareFn?: (a: T, b: T) => number): this; // /** // * Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. // * @param start The zero-based location in the array from which to start removing elements. @@ -124,7 +124,7 @@ // * @param thisArg An object to which the this keyword can refer in the predicate function. // * If thisArg is omitted, undefined is used as the this value. // */ -// every(predicate: (value: T, index: number, array: T[]) => value is S, thisArg?: any): this is S[]; +// every(/** @immediate */ predicate: (value: T, index: number, array: T[]) => value is S, thisArg?: any): this is S[]; // /** // * Determines whether all the members of an array satisfy the specified test. // * @param predicate A function that accepts up to three arguments. The every method calls @@ -133,7 +133,7 @@ // * @param thisArg An object to which the this keyword can refer in the predicate function. // * If thisArg is omitted, undefined is used as the this value. // */ -// every(predicate: (value: T, index: number, array: T[]) => unknown, thisArg?: any): boolean; +// every(/** @immediate */ predicate: (value: T, index: number, array: T[]) => unknown, thisArg?: any): boolean; // /** // * Determines whether the specified callback function returns true for any element of an array. // * @param predicate A function that accepts up to three arguments. The some method calls @@ -142,57 +142,57 @@ // * @param thisArg An object to which the this keyword can refer in the predicate function. // * If thisArg is omitted, undefined is used as the this value. // */ -// some(predicate: (value: T, index: number, array: T[]) => unknown, thisArg?: any): boolean; +// some(/** @immediate */ predicate: (value: T, index: number, array: T[]) => unknown, thisArg?: any): boolean; // /** // * Performs the specified action for each element in an array. // * @param callbackfn A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the array. // * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. // */ -// forEach(callbackfn: (value: T, index: number, array: T[]) => void, thisArg?: any): void; +// forEach(/** @immediate */ callbackfn: (value: T, index: number, array: T[]) => void, thisArg?: any): void; // /** // * Calls a defined callback function on each element of an array, and returns an array that contains the results. // * @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array. // * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. // */ -// map(callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): U[]; +// map(/** @immediate */ callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): U[]; // /** // * Returns the elements of an array that meet the condition specified in a callback function. // * @param predicate A function that accepts up to three arguments. The filter method calls the predicate function one time for each element in the array. // * @param thisArg An object to which the this keyword can refer in the predicate function. If thisArg is omitted, undefined is used as the this value. // */ -// filter(predicate: (value: T, index: number, array: T[]) => value is S, thisArg?: any): S[]; +// filter(/** @immediate */ predicate: (value: T, index: number, array: T[]) => value is S, thisArg?: any): S[]; // /** // * Returns the elements of an array that meet the condition specified in a callback function. // * @param predicate A function that accepts up to three arguments. The filter method calls the predicate function one time for each element in the array. // * @param thisArg An object to which the this keyword can refer in the predicate function. If thisArg is omitted, undefined is used as the this value. // */ -// filter(predicate: (value: T, index: number, array: T[]) => unknown, thisArg?: any): T[]; +// filter(/** @immediate */ predicate: (value: T, index: number, array: T[]) => unknown, thisArg?: any): T[]; // /** // * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. // * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array. // * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. // */ -// reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T): T; -// reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue: T): T; +// reduce(/** @immediate */ callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T): T; +// reduce(/** @immediate */ callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue: T): T; // /** // * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. // * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array. // * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. // */ -// reduce(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; +// reduce(/** @immediate */ callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; // /** // * Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. // * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array. // * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. // */ -// reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T): T; -// reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue: T): T; +// reduceRight(/** @immediate */ callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T): T; +// reduceRight(/** @immediate */ callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue: T): T; // /** // * Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. // * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array. // * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. // */ -// reduceRight(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; +// reduceRight(/** @immediate */ callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; // // [n: number]: T; // }|> @@ -336,7 +336,7 @@ // * [11,2,22,1].sort((a, b) => a - b) // * ``` // */ -// sort(compareFn?: (a: T, b: T) => number): this; +// sort(/** @immediate */ compareFn?: (a: T, b: T) => number): this; // /** // * Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. // * @param start The zero-based location in the array from which to start removing elements. @@ -377,7 +377,7 @@ // * @param thisArg An object to which the this keyword can refer in the predicate function. // * If thisArg is omitted, undefined is used as the this value. // */ -// every(predicate: (value: T, index: number, array: T[]) => value is S, thisArg?: any): this is S[]; +// every(/** @immediate */ predicate: (value: T, index: number, array: T[]) => value is S, thisArg?: any): this is S[]; // /** // * Determines whether all the members of an array satisfy the specified test. // * @param predicate A function that accepts up to three arguments. The every method calls @@ -386,7 +386,7 @@ // * @param thisArg An object to which the this keyword can refer in the predicate function. // * If thisArg is omitted, undefined is used as the this value. // */ -// every(predicate: (value: T, index: number, array: T[]) => unknown, thisArg?: any): boolean; +// every(/** @immediate */ predicate: (value: T, index: number, array: T[]) => unknown, thisArg?: any): boolean; // /** // * Determines whether the specified callback function returns true for any element of an array. // * @param predicate A function that accepts up to three arguments. The some method calls @@ -395,57 +395,57 @@ // * @param thisArg An object to which the this keyword can refer in the predicate function. // * If thisArg is omitted, undefined is used as the this value. // */ -// some(predicate: (value: T, index: number, array: T[]) => unknown, thisArg?: any): boolean; +// some(/** @immediate */ predicate: (value: T, index: number, array: T[]) => unknown, thisArg?: any): boolean; // /** // * Performs the specified action for each element in an array. // * @param callbackfn A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the array. // * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. // */ -// forEach(callbackfn: (value: T, index: number, array: T[]) => void, thisArg?: any): void; +// forEach(/** @immediate */ callbackfn: (value: T, index: number, array: T[]) => void, thisArg?: any): void; // /** // * Calls a defined callback function on each element of an array, and returns an array that contains the results. // * @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array. // * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. // */ -// map(callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): U[]; +// map(/** @immediate */ callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): U[]; // /** // * Returns the elements of an array that meet the condition specified in a callback function. // * @param predicate A function that accepts up to three arguments. The filter method calls the predicate function one time for each element in the array. // * @param thisArg An object to which the this keyword can refer in the predicate function. If thisArg is omitted, undefined is used as the this value. // */ -// filter(predicate: (value: T, index: number, array: T[]) => value is S, thisArg?: any): S[]; +// filter(/** @immediate */ predicate: (value: T, index: number, array: T[]) => value is S, thisArg?: any): S[]; // /** // * Returns the elements of an array that meet the condition specified in a callback function. // * @param predicate A function that accepts up to three arguments. The filter method calls the predicate function one time for each element in the array. // * @param thisArg An object to which the this keyword can refer in the predicate function. If thisArg is omitted, undefined is used as the this value. // */ -// filter(predicate: (value: T, index: number, array: T[]) => unknown, thisArg?: any): T[]; +// filter(/** @immediate */ predicate: (value: T, index: number, array: T[]) => unknown, thisArg?: any): T[]; // /** // * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. // * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array. // * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. // */ -// reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T): T; -// reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue: T): T; +// reduce(/** @immediate */ callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T): T; +// reduce(/** @immediate */ callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue: T): T; // /** // * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. // * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array. // * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. // */ -// reduce(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; +// reduce(/** @immediate */ callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; // /** // * Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. // * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array. // * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. // */ -// reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T): T; -// reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue: T): T; +// reduceRight(/** @immediate */ callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T): T; +// reduceRight(/** @immediate */ callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue: T): T; // /** // * Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. // * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array. // * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. // */ -// reduceRight(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; +// reduceRight(/** @immediate */ callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; // // [n: number]: T; // }|> diff --git a/tests/baselines/reference/immediateCallbacks.errors.txt b/tests/baselines/reference/immediateCallbacks.errors.txt new file mode 100644 index 0000000000000..8af77a41da372 --- /dev/null +++ b/tests/baselines/reference/immediateCallbacks.errors.txt @@ -0,0 +1,309 @@ +immediateCallbacks.ts(119,22): error TS2874: An 'immediate' parameter must have a type that permits functions. +immediateCallbacks.ts(120,22): error TS2874: An 'immediate' parameter must have a type that permits functions. +immediateCallbacks.ts(121,22): error TS2874: An 'immediate' parameter must have a type that permits functions. +immediateCallbacks.ts(128,13): error TS2874: An 'immediate' parameter must have a type that permits functions. +immediateCallbacks.ts(129,13): error TS2874: An 'immediate' parameter must have a type that permits functions. +immediateCallbacks.ts(130,13): error TS2874: An 'immediate' parameter must have a type that permits functions. +immediateCallbacks.ts(131,14): error TS1070: 'immediate' modifier cannot appear on a type member. + + +==== immediateCallbacks.ts (7 errors) ==== + declare function deferred(cb: () => void): void; + declare function immediate1(immediate cb: () => void): void; + declare function immediate2(/** @immediate */ cb: () => void): void; + declare function immediate3(/** @immediate */ immediate cb: () => void): void; + + function f01() { + let x: string | number = "OK"; + deferred(() => { + x = 42; + }); + x; // string + } + + function f02() { + let x: string | number = "OK"; + immediate1(() => { + x = 42; + }); + x; // string | number + } + + function f03() { + let x: string | number = "OK"; + immediate2(() => { + x = 42; + }); + x; // string | number + } + + function f04() { + let x: string | number = "OK"; + immediate3(() => { + x = 42; + }); + x; // string | number + } + + // Parameter is considered immediate if one or more overloads include the modifier in that parameter position + + declare function overloaded(cb: (x: T) => T): void; + declare function overloaded(cb: (x: T, y: T) => T): void; + declare function overloaded(immediate cb: (...args: any) => any): void; + + function f05() { + let x: string | number = "OK"; + overloaded(() => { + x = 42; + }); + x; // string | number + } + + // immediate is permitted on a rest parameter + + declare function invokeDeferred(...args: ((...args: any) => any)[]): void; + declare function invokeImmediate(immediate ...args: ((...args: any) => any)[]): void; + + function f06() { + let a = []; + a.push("abc"); + a; // string[] + invokeImmediate( + () => { + a; // string[] + a.push(42); + a; // (string | number)[] + }, + () => { + a; // string[] + a.push(true); + a; // (string | boolean)[] + } + ); + a; // (string | number | boolean)[] + } + + function f07() { + let a = []; + a.push("abc"); + a; // string[] + invokeDeferred( + () => { + a; // string[] + a.push(42); + a; // (string | number)[] + }, + () => { + a; // string[] + a.push(true); + a; // (string | boolean)[] + } + ); + a; // string[] + } + + // immediate modifier must precede public/private/protected/readonly + + class CC { + constructor(immediate public readonly x: () => void) {} + } + + // immediate requires parameter to have type that permits functions + + declare function f10(immediate f: () => void): void; + declare function f11(immediate f: Function): void; + declare function f12(immediate f: any): void; + declare function f13(immediate f: object): void; + declare function f14(immediate f: {}): void; + declare function f15(immediate f: unknown): void; + declare function f16(immediate f: T): void; + declare function f17 any>(immediate f: T): void; + declare function f18 void)>(immediate f: T): void; + + declare function f20(immediate ...funcs: Function[]): void; + declare function f21 any)[]>(immediate ...funcs: T): void; + declare function f22 void))[]>(immediate ...funcs: T): void; + declare function f23 void)[]>(immediate ...funcs: T): void; + declare function f24 void)[]>(immediate ...funcs: T | string[]): void; + + declare function f30(immediate f: { foo(): void }): void; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2874: An 'immediate' parameter must have a type that permits functions. + declare function f31(immediate f: number): void; + ~~~~~~~~~~~~~~~~~~~ +!!! error TS2874: An 'immediate' parameter must have a type that permits functions. + declare function f32(immediate ...funcs: number[]): void; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2874: An 'immediate' parameter must have a type that permits functions. + + type T10 = (immediate f: () => void) => void; + type T11 = (immediate f: { (): void }) => void; + type T12 = (immediate f: Function) => void; + type T13 = (immediate f: any) => void; + + type T20 = (immediate f: { foo(): void }) => void; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2874: An 'immediate' parameter must have a type that permits functions. + type T21 = (immediate f: number) => void; + ~~~~~~~~~~~~~~~~~~~ +!!! error TS2874: An 'immediate' parameter must have a type that permits functions. + type T22 = (immediate ...funcs: number[]) => void; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2874: An 'immediate' parameter must have a type that permits functions. + type T23 = { immediate x: () => void }; + ~~~~~~~~~ +!!! error TS1070: 'immediate' modifier cannot appear on a type member. + + // immediate modifier is not captured in argument list tuples + + declare function doStuff(immediate f: () => void): void; + + declare function recreate(f: (...args: A) => R): (...args: A) => R; + declare function recreateImmediate1(f: (immediate ...args: A) => R): (...args: A) => R; + declare function recreateImmediate2(f: (...args: A) => R): (immediate ...args: A) => R; + + function ff1() { + let x: string | number; + x = 123; + doStuff(() => { + x = "hi"; + }); + x; // string | number + } + + function ff2() { + let y: string | number; + y = 123; + recreate(doStuff)(() => { + y = "hi"; + }); + y; // number + } + + function ff3() { + let z: string | number; + z = 123; + recreateImmediate1(doStuff)(() => { + z = "hi"; + }); + z; // number + } + + function ff4() { + let z: string | number; + z = 123; + recreateImmediate2(doStuff)(() => { + z = "hi"; + }); + z; // string | number + } + + // Subtype reduction considers (cb: () => void) => a subtype of (immediate cb: () => void) => void + + declare function fa1(cb1: () => void): void; + declare function fa2(immediate cb2: () => void): void; + + const fa = Math.random() > 0.5 ? fa1 : fa2; + + function fta() { + let x: string | number = "OK"; + fa(() => { + x = 10; + }); + x; // string | number + } + + declare function fb1(cb1: () => void): void; + declare function fb2(immediate cb2: () => void): void; + + const fb = Math.random() > 0.5 ? fb2 : fb1; + + function ftb() { + let x: string | number = "OK"; + fb(() => { + x = 10; + }); + x; // string | number + } + + // A union signature parameter is immediate if any underlying parameter in same position is immediate + + declare const fc: ((immediate cb: () => void) => void) | ((cb: () => void) => void); + + function ftc() { + let x: string | number = "OK"; + fc(() => { + x = 10; + }); + x; // string | number + } + + declare const fd: ((cb: () => void) => void) | ((immediate cb: () => void) => void); + + function ftd() { + let x: string | number = "OK"; + fd(() => { + x = 10; + }); + x; // string | number + } + + // https://github.com/microsoft/TypeScript/issues/11498 + + declare function mystery(immediate cb: () => void): void; + + function fx1() { + let x: string | number = "OK"; + x; // string + mystery(() => { + x = 10; + }); + x; // string | number + if (x === 10) {} + } + + // https://github.com/microsoft/TypeScript/issues/15380 + + class Foo { + public bar: string = ""; + } + + function fx2() { + let foo: Foo | null = null; + [1].forEach((item) => { + foo = new Foo(); + }); + if (foo) { + foo.bar; + } + } + + // https://github.com/microsoft/TypeScript/issues/57880 + + const call = (immediate f: () => void) => f(); + + const fx3 = () => { + let a: undefined | number = undefined; + call(() => { a = 1; }); + if (a !== undefined) { + a.toString(); + } + }; + + // https://github.com/microsoft/TypeScript/issues/58291 + + async function execute(immediate onError: (_err: Error | undefined) => void) { + onError(new Error("a")); + } + + async function run() { + let result: boolean = true; + await execute(() => { + result = false; + }); + if (result === false) { + console.log("error"); + } + return result; + } + \ No newline at end of file diff --git a/tests/baselines/reference/immediateCallbacks.symbols b/tests/baselines/reference/immediateCallbacks.symbols new file mode 100644 index 0000000000000..5c9c51a50cbf3 --- /dev/null +++ b/tests/baselines/reference/immediateCallbacks.symbols @@ -0,0 +1,739 @@ +//// [tests/cases/compiler/immediateCallbacks.ts] //// + +=== immediateCallbacks.ts === +declare function deferred(cb: () => void): void; +>deferred : Symbol(deferred, Decl(immediateCallbacks.ts, 0, 0)) +>cb : Symbol(cb, Decl(immediateCallbacks.ts, 0, 26)) + +declare function immediate1(immediate cb: () => void): void; +>immediate1 : Symbol(immediate1, Decl(immediateCallbacks.ts, 0, 48)) +>cb : Symbol(cb, Decl(immediateCallbacks.ts, 1, 28)) + +declare function immediate2(/** @immediate */ cb: () => void): void; +>immediate2 : Symbol(immediate2, Decl(immediateCallbacks.ts, 1, 60)) +>cb : Symbol(cb, Decl(immediateCallbacks.ts, 2, 28)) + +declare function immediate3(/** @immediate */ immediate cb: () => void): void; +>immediate3 : Symbol(immediate3, Decl(immediateCallbacks.ts, 2, 68)) +>cb : Symbol(cb, Decl(immediateCallbacks.ts, 3, 28)) + +function f01() { +>f01 : Symbol(f01, Decl(immediateCallbacks.ts, 3, 78)) + + let x: string | number = "OK"; +>x : Symbol(x, Decl(immediateCallbacks.ts, 6, 7)) + + deferred(() => { +>deferred : Symbol(deferred, Decl(immediateCallbacks.ts, 0, 0)) + + x = 42; +>x : Symbol(x, Decl(immediateCallbacks.ts, 6, 7)) + + }); + x; // string +>x : Symbol(x, Decl(immediateCallbacks.ts, 6, 7)) +} + +function f02() { +>f02 : Symbol(f02, Decl(immediateCallbacks.ts, 11, 1)) + + let x: string | number = "OK"; +>x : Symbol(x, Decl(immediateCallbacks.ts, 14, 7)) + + immediate1(() => { +>immediate1 : Symbol(immediate1, Decl(immediateCallbacks.ts, 0, 48)) + + x = 42; +>x : Symbol(x, Decl(immediateCallbacks.ts, 14, 7)) + + }); + x; // string | number +>x : Symbol(x, Decl(immediateCallbacks.ts, 14, 7)) +} + +function f03() { +>f03 : Symbol(f03, Decl(immediateCallbacks.ts, 19, 1)) + + let x: string | number = "OK"; +>x : Symbol(x, Decl(immediateCallbacks.ts, 22, 7)) + + immediate2(() => { +>immediate2 : Symbol(immediate2, Decl(immediateCallbacks.ts, 1, 60)) + + x = 42; +>x : Symbol(x, Decl(immediateCallbacks.ts, 22, 7)) + + }); + x; // string | number +>x : Symbol(x, Decl(immediateCallbacks.ts, 22, 7)) +} + +function f04() { +>f04 : Symbol(f04, Decl(immediateCallbacks.ts, 27, 1)) + + let x: string | number = "OK"; +>x : Symbol(x, Decl(immediateCallbacks.ts, 30, 7)) + + immediate3(() => { +>immediate3 : Symbol(immediate3, Decl(immediateCallbacks.ts, 2, 68)) + + x = 42; +>x : Symbol(x, Decl(immediateCallbacks.ts, 30, 7)) + + }); + x; // string | number +>x : Symbol(x, Decl(immediateCallbacks.ts, 30, 7)) +} + +// Parameter is considered immediate if one or more overloads include the modifier in that parameter position + +declare function overloaded(cb: (x: T) => T): void; +>overloaded : Symbol(overloaded, Decl(immediateCallbacks.ts, 35, 1), Decl(immediateCallbacks.ts, 39, 54), Decl(immediateCallbacks.ts, 40, 60)) +>T : Symbol(T, Decl(immediateCallbacks.ts, 39, 28)) +>cb : Symbol(cb, Decl(immediateCallbacks.ts, 39, 31)) +>x : Symbol(x, Decl(immediateCallbacks.ts, 39, 36)) +>T : Symbol(T, Decl(immediateCallbacks.ts, 39, 28)) +>T : Symbol(T, Decl(immediateCallbacks.ts, 39, 28)) + +declare function overloaded(cb: (x: T, y: T) => T): void; +>overloaded : Symbol(overloaded, Decl(immediateCallbacks.ts, 35, 1), Decl(immediateCallbacks.ts, 39, 54), Decl(immediateCallbacks.ts, 40, 60)) +>T : Symbol(T, Decl(immediateCallbacks.ts, 40, 28)) +>cb : Symbol(cb, Decl(immediateCallbacks.ts, 40, 31)) +>x : Symbol(x, Decl(immediateCallbacks.ts, 40, 36)) +>T : Symbol(T, Decl(immediateCallbacks.ts, 40, 28)) +>y : Symbol(y, Decl(immediateCallbacks.ts, 40, 41)) +>T : Symbol(T, Decl(immediateCallbacks.ts, 40, 28)) +>T : Symbol(T, Decl(immediateCallbacks.ts, 40, 28)) + +declare function overloaded(immediate cb: (...args: any) => any): void; +>overloaded : Symbol(overloaded, Decl(immediateCallbacks.ts, 35, 1), Decl(immediateCallbacks.ts, 39, 54), Decl(immediateCallbacks.ts, 40, 60)) +>cb : Symbol(cb, Decl(immediateCallbacks.ts, 41, 28)) +>args : Symbol(args, Decl(immediateCallbacks.ts, 41, 43)) + +function f05() { +>f05 : Symbol(f05, Decl(immediateCallbacks.ts, 41, 71)) + + let x: string | number = "OK"; +>x : Symbol(x, Decl(immediateCallbacks.ts, 44, 7)) + + overloaded(() => { +>overloaded : Symbol(overloaded, Decl(immediateCallbacks.ts, 35, 1), Decl(immediateCallbacks.ts, 39, 54), Decl(immediateCallbacks.ts, 40, 60)) + + x = 42; +>x : Symbol(x, Decl(immediateCallbacks.ts, 44, 7)) + + }); + x; // string | number +>x : Symbol(x, Decl(immediateCallbacks.ts, 44, 7)) +} + +// immediate is permitted on a rest parameter + +declare function invokeDeferred(...args: ((...args: any) => any)[]): void; +>invokeDeferred : Symbol(invokeDeferred, Decl(immediateCallbacks.ts, 49, 1)) +>args : Symbol(args, Decl(immediateCallbacks.ts, 53, 32)) +>args : Symbol(args, Decl(immediateCallbacks.ts, 53, 43)) + +declare function invokeImmediate(immediate ...args: ((...args: any) => any)[]): void; +>invokeImmediate : Symbol(invokeImmediate, Decl(immediateCallbacks.ts, 53, 74)) +>args : Symbol(args, Decl(immediateCallbacks.ts, 54, 33)) +>args : Symbol(args, Decl(immediateCallbacks.ts, 54, 54)) + +function f06() { +>f06 : Symbol(f06, Decl(immediateCallbacks.ts, 54, 85)) + + let a = []; +>a : Symbol(a, Decl(immediateCallbacks.ts, 57, 7)) + + a.push("abc"); +>a.push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --)) +>a : Symbol(a, Decl(immediateCallbacks.ts, 57, 7)) +>push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --)) + + a; // string[] +>a : Symbol(a, Decl(immediateCallbacks.ts, 57, 7)) + + invokeImmediate( +>invokeImmediate : Symbol(invokeImmediate, Decl(immediateCallbacks.ts, 53, 74)) + + () => { + a; // string[] +>a : Symbol(a, Decl(immediateCallbacks.ts, 57, 7)) + + a.push(42); +>a.push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --)) +>a : Symbol(a, Decl(immediateCallbacks.ts, 57, 7)) +>push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --)) + + a; // (string | number)[] +>a : Symbol(a, Decl(immediateCallbacks.ts, 57, 7)) + + }, + () => { + a; // string[] +>a : Symbol(a, Decl(immediateCallbacks.ts, 57, 7)) + + a.push(true); +>a.push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --)) +>a : Symbol(a, Decl(immediateCallbacks.ts, 57, 7)) +>push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --)) + + a; // (string | boolean)[] +>a : Symbol(a, Decl(immediateCallbacks.ts, 57, 7)) + } + ); + a; // (string | number | boolean)[] +>a : Symbol(a, Decl(immediateCallbacks.ts, 57, 7)) +} + +function f07() { +>f07 : Symbol(f07, Decl(immediateCallbacks.ts, 73, 1)) + + let a = []; +>a : Symbol(a, Decl(immediateCallbacks.ts, 76, 7)) + + a.push("abc"); +>a.push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --)) +>a : Symbol(a, Decl(immediateCallbacks.ts, 76, 7)) +>push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --)) + + a; // string[] +>a : Symbol(a, Decl(immediateCallbacks.ts, 76, 7)) + + invokeDeferred( +>invokeDeferred : Symbol(invokeDeferred, Decl(immediateCallbacks.ts, 49, 1)) + + () => { + a; // string[] +>a : Symbol(a, Decl(immediateCallbacks.ts, 76, 7)) + + a.push(42); +>a.push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --)) +>a : Symbol(a, Decl(immediateCallbacks.ts, 76, 7)) +>push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --)) + + a; // (string | number)[] +>a : Symbol(a, Decl(immediateCallbacks.ts, 76, 7)) + + }, + () => { + a; // string[] +>a : Symbol(a, Decl(immediateCallbacks.ts, 76, 7)) + + a.push(true); +>a.push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --)) +>a : Symbol(a, Decl(immediateCallbacks.ts, 76, 7)) +>push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --)) + + a; // (string | boolean)[] +>a : Symbol(a, Decl(immediateCallbacks.ts, 76, 7)) + } + ); + a; // string[] +>a : Symbol(a, Decl(immediateCallbacks.ts, 76, 7)) +} + +// immediate modifier must precede public/private/protected/readonly + +class CC { +>CC : Symbol(CC, Decl(immediateCallbacks.ts, 92, 1)) + + constructor(immediate public readonly x: () => void) {} +>x : Symbol(CC.x, Decl(immediateCallbacks.ts, 97, 16)) +} + +// immediate requires parameter to have type that permits functions + +declare function f10(immediate f: () => void): void; +>f10 : Symbol(f10, Decl(immediateCallbacks.ts, 98, 1)) +>f : Symbol(f, Decl(immediateCallbacks.ts, 102, 21)) + +declare function f11(immediate f: Function): void; +>f11 : Symbol(f11, Decl(immediateCallbacks.ts, 102, 52)) +>f : Symbol(f, Decl(immediateCallbacks.ts, 103, 21)) +>Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.esnext.decorators.d.ts, --, --)) + +declare function f12(immediate f: any): void; +>f12 : Symbol(f12, Decl(immediateCallbacks.ts, 103, 50)) +>f : Symbol(f, Decl(immediateCallbacks.ts, 104, 21)) + +declare function f13(immediate f: object): void; +>f13 : Symbol(f13, Decl(immediateCallbacks.ts, 104, 45)) +>f : Symbol(f, Decl(immediateCallbacks.ts, 105, 21)) + +declare function f14(immediate f: {}): void; +>f14 : Symbol(f14, Decl(immediateCallbacks.ts, 105, 48)) +>f : Symbol(f, Decl(immediateCallbacks.ts, 106, 21)) + +declare function f15(immediate f: unknown): void; +>f15 : Symbol(f15, Decl(immediateCallbacks.ts, 106, 44)) +>f : Symbol(f, Decl(immediateCallbacks.ts, 107, 21)) + +declare function f16(immediate f: T): void; +>f16 : Symbol(f16, Decl(immediateCallbacks.ts, 107, 49)) +>T : Symbol(T, Decl(immediateCallbacks.ts, 108, 21)) +>Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.esnext.decorators.d.ts, --, --)) +>f : Symbol(f, Decl(immediateCallbacks.ts, 108, 41)) +>T : Symbol(T, Decl(immediateCallbacks.ts, 108, 21)) + +declare function f17 any>(immediate f: T): void; +>f17 : Symbol(f17, Decl(immediateCallbacks.ts, 108, 63)) +>T : Symbol(T, Decl(immediateCallbacks.ts, 109, 21)) +>args : Symbol(args, Decl(immediateCallbacks.ts, 109, 32)) +>f : Symbol(f, Decl(immediateCallbacks.ts, 109, 54)) +>T : Symbol(T, Decl(immediateCallbacks.ts, 109, 21)) + +declare function f18 void)>(immediate f: T): void; +>f18 : Symbol(f18, Decl(immediateCallbacks.ts, 109, 76)) +>T : Symbol(T, Decl(immediateCallbacks.ts, 110, 21)) +>f : Symbol(f, Decl(immediateCallbacks.ts, 110, 54)) +>T : Symbol(T, Decl(immediateCallbacks.ts, 110, 21)) + +declare function f20(immediate ...funcs: Function[]): void; +>f20 : Symbol(f20, Decl(immediateCallbacks.ts, 110, 76)) +>funcs : Symbol(funcs, Decl(immediateCallbacks.ts, 112, 21)) +>Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.esnext.decorators.d.ts, --, --)) + +declare function f21 any)[]>(immediate ...funcs: T): void; +>f21 : Symbol(f21, Decl(immediateCallbacks.ts, 112, 59)) +>T : Symbol(T, Decl(immediateCallbacks.ts, 113, 21)) +>args : Symbol(args, Decl(immediateCallbacks.ts, 113, 33)) +>funcs : Symbol(funcs, Decl(immediateCallbacks.ts, 113, 58)) +>T : Symbol(T, Decl(immediateCallbacks.ts, 113, 21)) + +declare function f22 void))[]>(immediate ...funcs: T): void; +>f22 : Symbol(f22, Decl(immediateCallbacks.ts, 113, 87)) +>T : Symbol(T, Decl(immediateCallbacks.ts, 114, 21)) +>funcs : Symbol(funcs, Decl(immediateCallbacks.ts, 114, 58)) +>T : Symbol(T, Decl(immediateCallbacks.ts, 114, 21)) + +declare function f23 void)[]>(immediate ...funcs: T): void; +>f23 : Symbol(f23, Decl(immediateCallbacks.ts, 114, 87)) +>T : Symbol(T, Decl(immediateCallbacks.ts, 115, 21)) +>funcs : Symbol(funcs, Decl(immediateCallbacks.ts, 115, 58)) +>T : Symbol(T, Decl(immediateCallbacks.ts, 115, 21)) + +declare function f24 void)[]>(immediate ...funcs: T | string[]): void; +>f24 : Symbol(f24, Decl(immediateCallbacks.ts, 115, 87)) +>T : Symbol(T, Decl(immediateCallbacks.ts, 116, 21)) +>funcs : Symbol(funcs, Decl(immediateCallbacks.ts, 116, 47)) +>T : Symbol(T, Decl(immediateCallbacks.ts, 116, 21)) + +declare function f30(immediate f: { foo(): void }): void; +>f30 : Symbol(f30, Decl(immediateCallbacks.ts, 116, 87)) +>f : Symbol(f, Decl(immediateCallbacks.ts, 118, 21)) +>foo : Symbol(foo, Decl(immediateCallbacks.ts, 118, 35)) + +declare function f31(immediate f: number): void; +>f31 : Symbol(f31, Decl(immediateCallbacks.ts, 118, 57)) +>f : Symbol(f, Decl(immediateCallbacks.ts, 119, 21)) + +declare function f32(immediate ...funcs: number[]): void; +>f32 : Symbol(f32, Decl(immediateCallbacks.ts, 119, 48)) +>funcs : Symbol(funcs, Decl(immediateCallbacks.ts, 120, 21)) + +type T10 = (immediate f: () => void) => void; +>T10 : Symbol(T10, Decl(immediateCallbacks.ts, 120, 57)) +>f : Symbol(f, Decl(immediateCallbacks.ts, 122, 12)) + +type T11 = (immediate f: { (): void }) => void; +>T11 : Symbol(T11, Decl(immediateCallbacks.ts, 122, 45)) +>f : Symbol(f, Decl(immediateCallbacks.ts, 123, 12)) + +type T12 = (immediate f: Function) => void; +>T12 : Symbol(T12, Decl(immediateCallbacks.ts, 123, 47)) +>f : Symbol(f, Decl(immediateCallbacks.ts, 124, 12)) +>Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.esnext.decorators.d.ts, --, --)) + +type T13 = (immediate f: any) => void; +>T13 : Symbol(T13, Decl(immediateCallbacks.ts, 124, 43)) +>f : Symbol(f, Decl(immediateCallbacks.ts, 125, 12)) + +type T20 = (immediate f: { foo(): void }) => void; +>T20 : Symbol(T20, Decl(immediateCallbacks.ts, 125, 38)) +>f : Symbol(f, Decl(immediateCallbacks.ts, 127, 12)) +>foo : Symbol(foo, Decl(immediateCallbacks.ts, 127, 26)) + +type T21 = (immediate f: number) => void; +>T21 : Symbol(T21, Decl(immediateCallbacks.ts, 127, 50)) +>f : Symbol(f, Decl(immediateCallbacks.ts, 128, 12)) + +type T22 = (immediate ...funcs: number[]) => void; +>T22 : Symbol(T22, Decl(immediateCallbacks.ts, 128, 41)) +>funcs : Symbol(funcs, Decl(immediateCallbacks.ts, 129, 12)) + +type T23 = { immediate x: () => void }; +>T23 : Symbol(T23, Decl(immediateCallbacks.ts, 129, 50)) +>x : Symbol(x, Decl(immediateCallbacks.ts, 130, 12)) + +// immediate modifier is not captured in argument list tuples + +declare function doStuff(immediate f: () => void): void; +>doStuff : Symbol(doStuff, Decl(immediateCallbacks.ts, 130, 39)) +>f : Symbol(f, Decl(immediateCallbacks.ts, 134, 25)) + +declare function recreate(f: (...args: A) => R): (...args: A) => R; +>recreate : Symbol(recreate, Decl(immediateCallbacks.ts, 134, 56)) +>A : Symbol(A, Decl(immediateCallbacks.ts, 136, 26)) +>R : Symbol(R, Decl(immediateCallbacks.ts, 136, 46)) +>f : Symbol(f, Decl(immediateCallbacks.ts, 136, 50)) +>args : Symbol(args, Decl(immediateCallbacks.ts, 136, 54)) +>A : Symbol(A, Decl(immediateCallbacks.ts, 136, 26)) +>R : Symbol(R, Decl(immediateCallbacks.ts, 136, 46)) +>args : Symbol(args, Decl(immediateCallbacks.ts, 136, 74)) +>A : Symbol(A, Decl(immediateCallbacks.ts, 136, 26)) +>R : Symbol(R, Decl(immediateCallbacks.ts, 136, 46)) + +declare function recreateImmediate1(f: (immediate ...args: A) => R): (...args: A) => R; +>recreateImmediate1 : Symbol(recreateImmediate1, Decl(immediateCallbacks.ts, 136, 91)) +>A : Symbol(A, Decl(immediateCallbacks.ts, 137, 36)) +>R : Symbol(R, Decl(immediateCallbacks.ts, 137, 56)) +>f : Symbol(f, Decl(immediateCallbacks.ts, 137, 60)) +>args : Symbol(args, Decl(immediateCallbacks.ts, 137, 64)) +>A : Symbol(A, Decl(immediateCallbacks.ts, 137, 36)) +>R : Symbol(R, Decl(immediateCallbacks.ts, 137, 56)) +>args : Symbol(args, Decl(immediateCallbacks.ts, 137, 94)) +>A : Symbol(A, Decl(immediateCallbacks.ts, 137, 36)) +>R : Symbol(R, Decl(immediateCallbacks.ts, 137, 56)) + +declare function recreateImmediate2(f: (...args: A) => R): (immediate ...args: A) => R; +>recreateImmediate2 : Symbol(recreateImmediate2, Decl(immediateCallbacks.ts, 137, 111)) +>A : Symbol(A, Decl(immediateCallbacks.ts, 138, 36)) +>R : Symbol(R, Decl(immediateCallbacks.ts, 138, 56)) +>f : Symbol(f, Decl(immediateCallbacks.ts, 138, 60)) +>args : Symbol(args, Decl(immediateCallbacks.ts, 138, 64)) +>A : Symbol(A, Decl(immediateCallbacks.ts, 138, 36)) +>R : Symbol(R, Decl(immediateCallbacks.ts, 138, 56)) +>args : Symbol(args, Decl(immediateCallbacks.ts, 138, 84)) +>A : Symbol(A, Decl(immediateCallbacks.ts, 138, 36)) +>R : Symbol(R, Decl(immediateCallbacks.ts, 138, 56)) + +function ff1() { +>ff1 : Symbol(ff1, Decl(immediateCallbacks.ts, 138, 111)) + + let x: string | number; +>x : Symbol(x, Decl(immediateCallbacks.ts, 141, 7)) + + x = 123; +>x : Symbol(x, Decl(immediateCallbacks.ts, 141, 7)) + + doStuff(() => { +>doStuff : Symbol(doStuff, Decl(immediateCallbacks.ts, 130, 39)) + + x = "hi"; +>x : Symbol(x, Decl(immediateCallbacks.ts, 141, 7)) + + }); + x; // string | number +>x : Symbol(x, Decl(immediateCallbacks.ts, 141, 7)) +} + +function ff2() { +>ff2 : Symbol(ff2, Decl(immediateCallbacks.ts, 147, 1)) + + let y: string | number; +>y : Symbol(y, Decl(immediateCallbacks.ts, 150, 7)) + + y = 123; +>y : Symbol(y, Decl(immediateCallbacks.ts, 150, 7)) + + recreate(doStuff)(() => { +>recreate : Symbol(recreate, Decl(immediateCallbacks.ts, 134, 56)) +>doStuff : Symbol(doStuff, Decl(immediateCallbacks.ts, 130, 39)) + + y = "hi"; +>y : Symbol(y, Decl(immediateCallbacks.ts, 150, 7)) + + }); + y; // number +>y : Symbol(y, Decl(immediateCallbacks.ts, 150, 7)) +} + +function ff3() { +>ff3 : Symbol(ff3, Decl(immediateCallbacks.ts, 156, 1)) + + let z: string | number; +>z : Symbol(z, Decl(immediateCallbacks.ts, 159, 7)) + + z = 123; +>z : Symbol(z, Decl(immediateCallbacks.ts, 159, 7)) + + recreateImmediate1(doStuff)(() => { +>recreateImmediate1 : Symbol(recreateImmediate1, Decl(immediateCallbacks.ts, 136, 91)) +>doStuff : Symbol(doStuff, Decl(immediateCallbacks.ts, 130, 39)) + + z = "hi"; +>z : Symbol(z, Decl(immediateCallbacks.ts, 159, 7)) + + }); + z; // number +>z : Symbol(z, Decl(immediateCallbacks.ts, 159, 7)) +} + +function ff4() { +>ff4 : Symbol(ff4, Decl(immediateCallbacks.ts, 165, 1)) + + let z: string | number; +>z : Symbol(z, Decl(immediateCallbacks.ts, 168, 7)) + + z = 123; +>z : Symbol(z, Decl(immediateCallbacks.ts, 168, 7)) + + recreateImmediate2(doStuff)(() => { +>recreateImmediate2 : Symbol(recreateImmediate2, Decl(immediateCallbacks.ts, 137, 111)) +>doStuff : Symbol(doStuff, Decl(immediateCallbacks.ts, 130, 39)) + + z = "hi"; +>z : Symbol(z, Decl(immediateCallbacks.ts, 168, 7)) + + }); + z; // string | number +>z : Symbol(z, Decl(immediateCallbacks.ts, 168, 7)) +} + +// Subtype reduction considers (cb: () => void) => a subtype of (immediate cb: () => void) => void + +declare function fa1(cb1: () => void): void; +>fa1 : Symbol(fa1, Decl(immediateCallbacks.ts, 174, 1)) +>cb1 : Symbol(cb1, Decl(immediateCallbacks.ts, 178, 21)) + +declare function fa2(immediate cb2: () => void): void; +>fa2 : Symbol(fa2, Decl(immediateCallbacks.ts, 178, 44)) +>cb2 : Symbol(cb2, Decl(immediateCallbacks.ts, 179, 21)) + +const fa = Math.random() > 0.5 ? fa1 : fa2; +>fa : Symbol(fa, Decl(immediateCallbacks.ts, 181, 5)) +>Math.random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --)) +>Math : Symbol(Math, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) +>random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --)) +>fa1 : Symbol(fa1, Decl(immediateCallbacks.ts, 174, 1)) +>fa2 : Symbol(fa2, Decl(immediateCallbacks.ts, 178, 44)) + +function fta() { +>fta : Symbol(fta, Decl(immediateCallbacks.ts, 181, 43)) + + let x: string | number = "OK"; +>x : Symbol(x, Decl(immediateCallbacks.ts, 184, 7)) + + fa(() => { +>fa : Symbol(fa, Decl(immediateCallbacks.ts, 181, 5)) + + x = 10; +>x : Symbol(x, Decl(immediateCallbacks.ts, 184, 7)) + + }); + x; // string | number +>x : Symbol(x, Decl(immediateCallbacks.ts, 184, 7)) +} + +declare function fb1(cb1: () => void): void; +>fb1 : Symbol(fb1, Decl(immediateCallbacks.ts, 189, 1)) +>cb1 : Symbol(cb1, Decl(immediateCallbacks.ts, 191, 21)) + +declare function fb2(immediate cb2: () => void): void; +>fb2 : Symbol(fb2, Decl(immediateCallbacks.ts, 191, 44)) +>cb2 : Symbol(cb2, Decl(immediateCallbacks.ts, 192, 21)) + +const fb = Math.random() > 0.5 ? fb2 : fb1; +>fb : Symbol(fb, Decl(immediateCallbacks.ts, 194, 5)) +>Math.random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --)) +>Math : Symbol(Math, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) +>random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --)) +>fb2 : Symbol(fb2, Decl(immediateCallbacks.ts, 191, 44)) +>fb1 : Symbol(fb1, Decl(immediateCallbacks.ts, 189, 1)) + +function ftb() { +>ftb : Symbol(ftb, Decl(immediateCallbacks.ts, 194, 43)) + + let x: string | number = "OK"; +>x : Symbol(x, Decl(immediateCallbacks.ts, 197, 7)) + + fb(() => { +>fb : Symbol(fb, Decl(immediateCallbacks.ts, 194, 5)) + + x = 10; +>x : Symbol(x, Decl(immediateCallbacks.ts, 197, 7)) + + }); + x; // string | number +>x : Symbol(x, Decl(immediateCallbacks.ts, 197, 7)) +} + +// A union signature parameter is immediate if any underlying parameter in same position is immediate + +declare const fc: ((immediate cb: () => void) => void) | ((cb: () => void) => void); +>fc : Symbol(fc, Decl(immediateCallbacks.ts, 206, 13)) +>cb : Symbol(cb, Decl(immediateCallbacks.ts, 206, 20)) +>cb : Symbol(cb, Decl(immediateCallbacks.ts, 206, 59)) + +function ftc() { +>ftc : Symbol(ftc, Decl(immediateCallbacks.ts, 206, 84)) + + let x: string | number = "OK"; +>x : Symbol(x, Decl(immediateCallbacks.ts, 209, 7)) + + fc(() => { +>fc : Symbol(fc, Decl(immediateCallbacks.ts, 206, 13)) + + x = 10; +>x : Symbol(x, Decl(immediateCallbacks.ts, 209, 7)) + + }); + x; // string | number +>x : Symbol(x, Decl(immediateCallbacks.ts, 209, 7)) +} + +declare const fd: ((cb: () => void) => void) | ((immediate cb: () => void) => void); +>fd : Symbol(fd, Decl(immediateCallbacks.ts, 216, 13)) +>cb : Symbol(cb, Decl(immediateCallbacks.ts, 216, 20)) +>cb : Symbol(cb, Decl(immediateCallbacks.ts, 216, 49)) + +function ftd() { +>ftd : Symbol(ftd, Decl(immediateCallbacks.ts, 216, 84)) + + let x: string | number = "OK"; +>x : Symbol(x, Decl(immediateCallbacks.ts, 219, 7)) + + fd(() => { +>fd : Symbol(fd, Decl(immediateCallbacks.ts, 216, 13)) + + x = 10; +>x : Symbol(x, Decl(immediateCallbacks.ts, 219, 7)) + + }); + x; // string | number +>x : Symbol(x, Decl(immediateCallbacks.ts, 219, 7)) +} + +// https://github.com/microsoft/TypeScript/issues/11498 + +declare function mystery(immediate cb: () => void): void; +>mystery : Symbol(mystery, Decl(immediateCallbacks.ts, 224, 1)) +>cb : Symbol(cb, Decl(immediateCallbacks.ts, 228, 25)) + +function fx1() { +>fx1 : Symbol(fx1, Decl(immediateCallbacks.ts, 228, 57)) + + let x: string | number = "OK"; +>x : Symbol(x, Decl(immediateCallbacks.ts, 231, 7)) + + x; // string +>x : Symbol(x, Decl(immediateCallbacks.ts, 231, 7)) + + mystery(() => { +>mystery : Symbol(mystery, Decl(immediateCallbacks.ts, 224, 1)) + + x = 10; +>x : Symbol(x, Decl(immediateCallbacks.ts, 231, 7)) + + }); + x; // string | number +>x : Symbol(x, Decl(immediateCallbacks.ts, 231, 7)) + + if (x === 10) {} +>x : Symbol(x, Decl(immediateCallbacks.ts, 231, 7)) +} + +// https://github.com/microsoft/TypeScript/issues/15380 + +class Foo { +>Foo : Symbol(Foo, Decl(immediateCallbacks.ts, 238, 1)) + + public bar: string = ""; +>bar : Symbol(Foo.bar, Decl(immediateCallbacks.ts, 242, 11)) +} + +function fx2() { +>fx2 : Symbol(fx2, Decl(immediateCallbacks.ts, 244, 1)) + + let foo: Foo | null = null; +>foo : Symbol(foo, Decl(immediateCallbacks.ts, 247, 5)) +>Foo : Symbol(Foo, Decl(immediateCallbacks.ts, 238, 1)) + + [1].forEach((item) => { +>[1].forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --)) +>forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --)) +>item : Symbol(item, Decl(immediateCallbacks.ts, 248, 15)) + + foo = new Foo(); +>foo : Symbol(foo, Decl(immediateCallbacks.ts, 247, 5)) +>Foo : Symbol(Foo, Decl(immediateCallbacks.ts, 238, 1)) + + }); + if (foo) { +>foo : Symbol(foo, Decl(immediateCallbacks.ts, 247, 5)) + + foo.bar; +>foo.bar : Symbol(Foo.bar, Decl(immediateCallbacks.ts, 242, 11)) +>foo : Symbol(foo, Decl(immediateCallbacks.ts, 247, 5)) +>bar : Symbol(Foo.bar, Decl(immediateCallbacks.ts, 242, 11)) + } +} + +// https://github.com/microsoft/TypeScript/issues/57880 + +const call = (immediate f: () => void) => f(); +>call : Symbol(call, Decl(immediateCallbacks.ts, 258, 5)) +>f : Symbol(f, Decl(immediateCallbacks.ts, 258, 14)) +>f : Symbol(f, Decl(immediateCallbacks.ts, 258, 14)) + +const fx3 = () => { +>fx3 : Symbol(fx3, Decl(immediateCallbacks.ts, 260, 5)) + + let a: undefined | number = undefined; +>a : Symbol(a, Decl(immediateCallbacks.ts, 261, 7)) +>undefined : Symbol(undefined) + + call(() => { a = 1; }); +>call : Symbol(call, Decl(immediateCallbacks.ts, 258, 5)) +>a : Symbol(a, Decl(immediateCallbacks.ts, 261, 7)) + + if (a !== undefined) { +>a : Symbol(a, Decl(immediateCallbacks.ts, 261, 7)) +>undefined : Symbol(undefined) + + a.toString(); +>a.toString : Symbol(Number.toString, Decl(lib.es5.d.ts, --, --)) +>a : Symbol(a, Decl(immediateCallbacks.ts, 261, 7)) +>toString : Symbol(Number.toString, Decl(lib.es5.d.ts, --, --)) + } +}; + +// https://github.com/microsoft/TypeScript/issues/58291 + +async function execute(immediate onError: (_err: Error | undefined) => void) { +>execute : Symbol(execute, Decl(immediateCallbacks.ts, 266, 2)) +>onError : Symbol(onError, Decl(immediateCallbacks.ts, 270, 23)) +>_err : Symbol(_err, Decl(immediateCallbacks.ts, 270, 43)) +>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2022.error.d.ts, --, --)) + + onError(new Error("a")); +>onError : Symbol(onError, Decl(immediateCallbacks.ts, 270, 23)) +>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2022.error.d.ts, --, --)) +} + +async function run() { +>run : Symbol(run, Decl(immediateCallbacks.ts, 272, 1)) + + let result: boolean = true; +>result : Symbol(result, Decl(immediateCallbacks.ts, 275, 7)) + + await execute(() => { +>execute : Symbol(execute, Decl(immediateCallbacks.ts, 266, 2)) + + result = false; +>result : Symbol(result, Decl(immediateCallbacks.ts, 275, 7)) + + }); + if (result === false) { +>result : Symbol(result, Decl(immediateCallbacks.ts, 275, 7)) + + console.log("error"); +>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +>console : Symbol(console, Decl(lib.dom.d.ts, --, --)) +>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) + } + return result; +>result : Symbol(result, Decl(immediateCallbacks.ts, 275, 7)) +} + diff --git a/tests/baselines/reference/immediateCallbacks.types b/tests/baselines/reference/immediateCallbacks.types new file mode 100644 index 0000000000000..65762f1c9757e --- /dev/null +++ b/tests/baselines/reference/immediateCallbacks.types @@ -0,0 +1,1247 @@ +//// [tests/cases/compiler/immediateCallbacks.ts] //// + +=== immediateCallbacks.ts === +declare function deferred(cb: () => void): void; +>deferred : (cb: () => void) => void +> : ^ ^^ ^^^^^ +>cb : () => void +> : ^^^^^^ + +declare function immediate1(immediate cb: () => void): void; +>immediate1 : (cb: () => void) => void +> : ^ ^^ ^^^^^ +>cb : () => void +> : ^^^^^^ + +declare function immediate2(/** @immediate */ cb: () => void): void; +>immediate2 : (cb: () => void) => void +> : ^ ^^ ^^^^^ +>cb : () => void +> : ^^^^^^ + +declare function immediate3(/** @immediate */ immediate cb: () => void): void; +>immediate3 : (cb: () => void) => void +> : ^ ^^ ^^^^^ +>cb : () => void +> : ^^^^^^ + +function f01() { +>f01 : () => void +> : ^^^^^^^^^^ + + let x: string | number = "OK"; +>x : string | number +> : ^^^^^^^^^^^^^^^ +>"OK" : "OK" +> : ^^^^ + + deferred(() => { +>deferred(() => { x = 42; }) : void +> : ^^^^ +>deferred : (cb: () => void) => void +> : ^ ^^ ^^^^^ +>() => { x = 42; } : () => void +> : ^^^^^^^^^^ + + x = 42; +>x = 42 : 42 +> : ^^ +>x : string | number +> : ^^^^^^^^^^^^^^^ +>42 : 42 +> : ^^ + + }); + x; // string +>x : string +> : ^^^^^^ +} + +function f02() { +>f02 : () => void +> : ^^^^^^^^^^ + + let x: string | number = "OK"; +>x : string | number +> : ^^^^^^^^^^^^^^^ +>"OK" : "OK" +> : ^^^^ + + immediate1(() => { +>immediate1(() => { x = 42; }) : void +> : ^^^^ +>immediate1 : (cb: () => void) => void +> : ^ ^^ ^^^^^ +>() => { x = 42; } : () => void +> : ^^^^^^^^^^ + + x = 42; +>x = 42 : 42 +> : ^^ +>x : string | number +> : ^^^^^^^^^^^^^^^ +>42 : 42 +> : ^^ + + }); + x; // string | number +>x : string | number +> : ^^^^^^^^^^^^^^^ +} + +function f03() { +>f03 : () => void +> : ^^^^^^^^^^ + + let x: string | number = "OK"; +>x : string | number +> : ^^^^^^^^^^^^^^^ +>"OK" : "OK" +> : ^^^^ + + immediate2(() => { +>immediate2(() => { x = 42; }) : void +> : ^^^^ +>immediate2 : (cb: () => void) => void +> : ^ ^^ ^^^^^ +>() => { x = 42; } : () => void +> : ^^^^^^^^^^ + + x = 42; +>x = 42 : 42 +> : ^^ +>x : string | number +> : ^^^^^^^^^^^^^^^ +>42 : 42 +> : ^^ + + }); + x; // string | number +>x : string | number +> : ^^^^^^^^^^^^^^^ +} + +function f04() { +>f04 : () => void +> : ^^^^^^^^^^ + + let x: string | number = "OK"; +>x : string | number +> : ^^^^^^^^^^^^^^^ +>"OK" : "OK" +> : ^^^^ + + immediate3(() => { +>immediate3(() => { x = 42; }) : void +> : ^^^^ +>immediate3 : (cb: () => void) => void +> : ^ ^^ ^^^^^ +>() => { x = 42; } : () => void +> : ^^^^^^^^^^ + + x = 42; +>x = 42 : 42 +> : ^^ +>x : string | number +> : ^^^^^^^^^^^^^^^ +>42 : 42 +> : ^^ + + }); + x; // string | number +>x : string | number +> : ^^^^^^^^^^^^^^^ +} + +// Parameter is considered immediate if one or more overloads include the modifier in that parameter position + +declare function overloaded(cb: (x: T) => T): void; +>overloaded : { (cb: (x: T) => T): void; (cb: (x: T_1, y: T_1) => T_1): void; (cb: (...args: any) => any): void; } +> : ^^^ ^^ ^^ ^^^ ^^^^^^^^ ^^ ^^^ ^^^ ^^ ^^^ ^^^ +>cb : (x: T) => T +> : ^ ^^ ^^^^^ +>x : T +> : ^ + +declare function overloaded(cb: (x: T, y: T) => T): void; +>overloaded : { (cb: (x: T_1) => T_1): void; (cb: (x: T, y: T) => T): void; (cb: (...args: any) => any): void; } +> : ^^^^^^^^ ^^ ^^^ ^^^ ^^ ^^ ^^^ ^^^ ^^ ^^^ ^^^ +>cb : (x: T, y: T) => T +> : ^ ^^ ^^ ^^ ^^^^^ +>x : T +> : ^ +>y : T +> : ^ + +declare function overloaded(immediate cb: (...args: any) => any): void; +>overloaded : { (cb: (x: T) => T): void; (cb: (x: T, y: T) => T): void; (cb: (...args: any) => any): void; } +> : ^^^ ^^ ^^ ^^^ ^^^ ^^ ^^ ^^^ ^^^ ^^ ^^^ ^^^ +>cb : (...args: any) => any +> : ^^^^ ^^ ^^^^^ +>args : any +> : ^^^ + +function f05() { +>f05 : () => void +> : ^^^^^^^^^^ + + let x: string | number = "OK"; +>x : string | number +> : ^^^^^^^^^^^^^^^ +>"OK" : "OK" +> : ^^^^ + + overloaded(() => { +>overloaded(() => { x = 42; }) : void +> : ^^^^ +>overloaded : { (cb: (x: T) => T): void; (cb: (x: T, y: T) => T): void; (cb: (...args: any) => any): void; } +> : ^^^ ^^ ^^ ^^^ ^^^ ^^ ^^ ^^^ ^^^ ^^ ^^^ ^^^ +>() => { x = 42; } : () => void +> : ^^^^^^^^^^ + + x = 42; +>x = 42 : 42 +> : ^^ +>x : string | number +> : ^^^^^^^^^^^^^^^ +>42 : 42 +> : ^^ + + }); + x; // string | number +>x : string | number +> : ^^^^^^^^^^^^^^^ +} + +// immediate is permitted on a rest parameter + +declare function invokeDeferred(...args: ((...args: any) => any)[]): void; +>invokeDeferred : (...args: ((...args: any) => any)[]) => void +> : ^^^^ ^^ ^^^^^ +>args : ((...args: any) => any)[] +> : ^^^^^ ^^ ^^^^^ ^^^ +>args : any +> : ^^^ + +declare function invokeImmediate(immediate ...args: ((...args: any) => any)[]): void; +>invokeImmediate : (...args: ((...args: any) => any)[]) => void +> : ^^^^ ^^ ^^^^^ +>args : ((...args: any) => any)[] +> : ^^^^^ ^^ ^^^^^ ^^^ +>args : any +> : ^^^ + +function f06() { +>f06 : () => void +> : ^^^^^^^^^^ + + let a = []; +>a : any[] +> : ^^^^^ +>[] : never[] +> : ^^^^^^^ + + a.push("abc"); +>a.push("abc") : number +> : ^^^^^^ +>a.push : (...items: any[]) => number +> : ^^^^ ^^^^^^^^^^^^ +>a : any[] +> : ^^^^^ +>push : (...items: any[]) => number +> : ^^^^ ^^^^^^^^^^^^ +>"abc" : "abc" +> : ^^^^^ + + a; // string[] +>a : string[] +> : ^^^^^^^^ + + invokeImmediate( +>invokeImmediate( () => { a; // string[] a.push(42); a; // (string | number)[] }, () => { a; // string[] a.push(true); a; // (string | boolean)[] } ) : void +> : ^^^^ +>invokeImmediate : (...args: ((...args: any) => any)[]) => void +> : ^^^^ ^^ ^^^^^ + + () => { +>() => { a; // string[] a.push(42); a; // (string | number)[] } : () => void +> : ^^^^^^^^^^ + + a; // string[] +>a : string[] +> : ^^^^^^^^ + + a.push(42); +>a.push(42) : number +> : ^^^^^^ +>a.push : (...items: any[]) => number +> : ^^^^ ^^^^^^^^^^^^ +>a : any[] +> : ^^^^^ +>push : (...items: any[]) => number +> : ^^^^ ^^^^^^^^^^^^ +>42 : 42 +> : ^^ + + a; // (string | number)[] +>a : (string | number)[] +> : ^^^^^^^^^^^^^^^^^^^ + + }, + () => { +>() => { a; // string[] a.push(true); a; // (string | boolean)[] } : () => void +> : ^^^^^^^^^^ + + a; // string[] +>a : string[] +> : ^^^^^^^^ + + a.push(true); +>a.push(true) : number +> : ^^^^^^ +>a.push : (...items: any[]) => number +> : ^^^^ ^^^^^^^^^^^^ +>a : any[] +> : ^^^^^ +>push : (...items: any[]) => number +> : ^^^^ ^^^^^^^^^^^^ +>true : true +> : ^^^^ + + a; // (string | boolean)[] +>a : (string | boolean)[] +> : ^^^^^^^^^^^^^^^^^^^^ + } + ); + a; // (string | number | boolean)[] +>a : (string | number | boolean)[] +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +} + +function f07() { +>f07 : () => void +> : ^^^^^^^^^^ + + let a = []; +>a : any[] +> : ^^^^^ +>[] : never[] +> : ^^^^^^^ + + a.push("abc"); +>a.push("abc") : number +> : ^^^^^^ +>a.push : (...items: any[]) => number +> : ^^^^ ^^^^^^^^^^^^ +>a : any[] +> : ^^^^^ +>push : (...items: any[]) => number +> : ^^^^ ^^^^^^^^^^^^ +>"abc" : "abc" +> : ^^^^^ + + a; // string[] +>a : string[] +> : ^^^^^^^^ + + invokeDeferred( +>invokeDeferred( () => { a; // string[] a.push(42); a; // (string | number)[] }, () => { a; // string[] a.push(true); a; // (string | boolean)[] } ) : void +> : ^^^^ +>invokeDeferred : (...args: ((...args: any) => any)[]) => void +> : ^^^^ ^^ ^^^^^ + + () => { +>() => { a; // string[] a.push(42); a; // (string | number)[] } : () => void +> : ^^^^^^^^^^ + + a; // string[] +>a : string[] +> : ^^^^^^^^ + + a.push(42); +>a.push(42) : number +> : ^^^^^^ +>a.push : (...items: any[]) => number +> : ^^^^ ^^^^^^^^^^^^ +>a : any[] +> : ^^^^^ +>push : (...items: any[]) => number +> : ^^^^ ^^^^^^^^^^^^ +>42 : 42 +> : ^^ + + a; // (string | number)[] +>a : (string | number)[] +> : ^^^^^^^^^^^^^^^^^^^ + + }, + () => { +>() => { a; // string[] a.push(true); a; // (string | boolean)[] } : () => void +> : ^^^^^^^^^^ + + a; // string[] +>a : string[] +> : ^^^^^^^^ + + a.push(true); +>a.push(true) : number +> : ^^^^^^ +>a.push : (...items: any[]) => number +> : ^^^^ ^^^^^^^^^^^^ +>a : any[] +> : ^^^^^ +>push : (...items: any[]) => number +> : ^^^^ ^^^^^^^^^^^^ +>true : true +> : ^^^^ + + a; // (string | boolean)[] +>a : (string | boolean)[] +> : ^^^^^^^^^^^^^^^^^^^^ + } + ); + a; // string[] +>a : string[] +> : ^^^^^^^^ +} + +// immediate modifier must precede public/private/protected/readonly + +class CC { +>CC : CC +> : ^^ + + constructor(immediate public readonly x: () => void) {} +>x : () => void +> : ^^^^^^ +} + +// immediate requires parameter to have type that permits functions + +declare function f10(immediate f: () => void): void; +>f10 : (f: () => void) => void +> : ^ ^^ ^^^^^ +>f : () => void +> : ^^^^^^ + +declare function f11(immediate f: Function): void; +>f11 : (f: Function) => void +> : ^ ^^ ^^^^^ +>f : Function +> : ^^^^^^^^ + +declare function f12(immediate f: any): void; +>f12 : (f: any) => void +> : ^ ^^ ^^^^^ +>f : any +> : ^^^ + +declare function f13(immediate f: object): void; +>f13 : (f: object) => void +> : ^ ^^ ^^^^^ +>f : object +> : ^^^^^^ + +declare function f14(immediate f: {}): void; +>f14 : (f: {}) => void +> : ^ ^^ ^^^^^ +>f : {} +> : ^^ + +declare function f15(immediate f: unknown): void; +>f15 : (f: unknown) => void +> : ^ ^^ ^^^^^ +>f : unknown +> : ^^^^^^^ + +declare function f16(immediate f: T): void; +>f16 : (f: T) => void +> : ^ ^^^^^^^^^ ^^ ^^ ^^^^^ +>f : T +> : ^ + +declare function f17 any>(immediate f: T): void; +>f17 : any>(f: T) => void +> : ^ ^^^^^^^^^ ^^ ^^ ^^^^^ +>args : any +> : ^^^ +>f : T +> : ^ + +declare function f18 void)>(immediate f: T): void; +>f18 : void)>(f: T) => void +> : ^ ^^^^^^^^^ ^^ ^^ ^^^^^ +>f : T +> : ^ + +declare function f20(immediate ...funcs: Function[]): void; +>f20 : (...funcs: Function[]) => void +> : ^^^^ ^^ ^^^^^ +>funcs : Function[] +> : ^^^^^^^^^^ + +declare function f21 any)[]>(immediate ...funcs: T): void; +>f21 : any)[]>(...funcs: T) => void +> : ^ ^^^^^^^^^ ^^^^^ ^^ ^^^^^ +>args : any +> : ^^^ +>funcs : T +> : ^ + +declare function f22 void))[]>(immediate ...funcs: T): void; +>f22 : void))[]>(...funcs: T) => void +> : ^ ^^^^^^^^^ ^^^^^ ^^ ^^^^^ +>funcs : T +> : ^ + +declare function f23 void)[]>(immediate ...funcs: T): void; +>f23 : void)[]>(...funcs: T) => void +> : ^ ^^^^^^^^^ ^^^^^ ^^ ^^^^^ +>funcs : T +> : ^ + +declare function f24 void)[]>(immediate ...funcs: T | string[]): void; +>f24 : void)[]>(...funcs: T | string[]) => void +> : ^ ^^^^^^^^^ ^^^^^ ^^ ^^^^^ +>funcs : string[] | T +> : ^^^^^^^^^^^^ + +declare function f30(immediate f: { foo(): void }): void; +>f30 : (f: { foo(): void; }) => void +> : ^ ^^ ^^^^^ +>f : { foo(): void; } +> : ^^^^^^^^^ ^^^ +>foo : () => void +> : ^^^^^^ + +declare function f31(immediate f: number): void; +>f31 : (f: number) => void +> : ^ ^^ ^^^^^ +>f : number +> : ^^^^^^ + +declare function f32(immediate ...funcs: number[]): void; +>f32 : (...funcs: number[]) => void +> : ^^^^ ^^ ^^^^^ +>funcs : number[] +> : ^^^^^^^^ + +type T10 = (immediate f: () => void) => void; +>T10 : T10 +> : ^^^ +>f : () => void +> : ^^^^^^ + +type T11 = (immediate f: { (): void }) => void; +>T11 : T11 +> : ^^^ +>f : () => void +> : ^^^^^^ + +type T12 = (immediate f: Function) => void; +>T12 : T12 +> : ^^^ +>f : Function +> : ^^^^^^^^ + +type T13 = (immediate f: any) => void; +>T13 : T13 +> : ^^^ +>f : any +> : ^^^ + +type T20 = (immediate f: { foo(): void }) => void; +>T20 : T20 +> : ^^^ +>f : { foo(): void; } +> : ^^^^^^^^^ ^^^ +>foo : () => void +> : ^^^^^^ + +type T21 = (immediate f: number) => void; +>T21 : T21 +> : ^^^ +>f : number +> : ^^^^^^ + +type T22 = (immediate ...funcs: number[]) => void; +>T22 : T22 +> : ^^^ +>funcs : number[] +> : ^^^^^^^^ + +type T23 = { immediate x: () => void }; +>T23 : T23 +> : ^^^ +>x : () => void +> : ^^^^^^ + +// immediate modifier is not captured in argument list tuples + +declare function doStuff(immediate f: () => void): void; +>doStuff : (f: () => void) => void +> : ^ ^^ ^^^^^ +>f : () => void +> : ^^^^^^ + +declare function recreate(f: (...args: A) => R): (...args: A) => R; +>recreate : (f: (...args: A) => R) => (...args: A) => R +> : ^ ^^^^^^^^^ ^^ ^^ ^^ ^^^^^ +>f : (...args: A) => R +> : ^^^^ ^^ ^^^^^ +>args : A +> : ^ +>args : A +> : ^ + +declare function recreateImmediate1(f: (immediate ...args: A) => R): (...args: A) => R; +>recreateImmediate1 : (f: (immediate ...args: A) => R) => (...args: A) => R +> : ^ ^^^^^^^^^ ^^ ^^ ^^ ^^^^^ +>f : (...args: A) => R +> : ^^^^ ^^ ^^^^^ +>args : A +> : ^ +>args : A +> : ^ + +declare function recreateImmediate2(f: (...args: A) => R): (immediate ...args: A) => R; +>recreateImmediate2 : (f: (...args: A) => R) => (immediate ...args: A) => R +> : ^ ^^^^^^^^^ ^^ ^^ ^^ ^^^^^ +>f : (...args: A) => R +> : ^^^^ ^^ ^^^^^ +>args : A +> : ^ +>args : A +> : ^ + +function ff1() { +>ff1 : () => void +> : ^^^^^^^^^^ + + let x: string | number; +>x : string | number +> : ^^^^^^^^^^^^^^^ + + x = 123; +>x = 123 : 123 +> : ^^^ +>x : string | number +> : ^^^^^^^^^^^^^^^ +>123 : 123 +> : ^^^ + + doStuff(() => { +>doStuff(() => { x = "hi"; }) : void +> : ^^^^ +>doStuff : (f: () => void) => void +> : ^ ^^ ^^^^^ +>() => { x = "hi"; } : () => void +> : ^^^^^^^^^^ + + x = "hi"; +>x = "hi" : "hi" +> : ^^^^ +>x : string | number +> : ^^^^^^^^^^^^^^^ +>"hi" : "hi" +> : ^^^^ + + }); + x; // string | number +>x : string | number +> : ^^^^^^^^^^^^^^^ +} + +function ff2() { +>ff2 : () => void +> : ^^^^^^^^^^ + + let y: string | number; +>y : string | number +> : ^^^^^^^^^^^^^^^ + + y = 123; +>y = 123 : 123 +> : ^^^ +>y : string | number +> : ^^^^^^^^^^^^^^^ +>123 : 123 +> : ^^^ + + recreate(doStuff)(() => { +>recreate(doStuff)(() => { y = "hi"; }) : void +> : ^^^^ +>recreate(doStuff) : (f: () => void) => void +> : ^^^^^^^^^^ ^^^^^^^^^ +>recreate : (f: (...args: A) => R) => (...args: A) => R +> : ^ ^^^^^^^^^ ^^ ^^ ^^ ^^^^^ +>doStuff : (f: () => void) => void +> : ^ ^^ ^^^^^ +>() => { y = "hi"; } : () => void +> : ^^^^^^^^^^ + + y = "hi"; +>y = "hi" : "hi" +> : ^^^^ +>y : string | number +> : ^^^^^^^^^^^^^^^ +>"hi" : "hi" +> : ^^^^ + + }); + y; // number +>y : number +> : ^^^^^^ +} + +function ff3() { +>ff3 : () => void +> : ^^^^^^^^^^ + + let z: string | number; +>z : string | number +> : ^^^^^^^^^^^^^^^ + + z = 123; +>z = 123 : 123 +> : ^^^ +>z : string | number +> : ^^^^^^^^^^^^^^^ +>123 : 123 +> : ^^^ + + recreateImmediate1(doStuff)(() => { +>recreateImmediate1(doStuff)(() => { z = "hi"; }) : void +> : ^^^^ +>recreateImmediate1(doStuff) : (f: () => void) => void +> : ^^^^^^^^^^ ^^^^^^^^^ +>recreateImmediate1 : (f: (immediate ...args: A) => R) => (...args: A) => R +> : ^ ^^^^^^^^^ ^^ ^^ ^^ ^^^^^ +>doStuff : (f: () => void) => void +> : ^ ^^ ^^^^^ +>() => { z = "hi"; } : () => void +> : ^^^^^^^^^^ + + z = "hi"; +>z = "hi" : "hi" +> : ^^^^ +>z : string | number +> : ^^^^^^^^^^^^^^^ +>"hi" : "hi" +> : ^^^^ + + }); + z; // number +>z : number +> : ^^^^^^ +} + +function ff4() { +>ff4 : () => void +> : ^^^^^^^^^^ + + let z: string | number; +>z : string | number +> : ^^^^^^^^^^^^^^^ + + z = 123; +>z = 123 : 123 +> : ^^^ +>z : string | number +> : ^^^^^^^^^^^^^^^ +>123 : 123 +> : ^^^ + + recreateImmediate2(doStuff)(() => { +>recreateImmediate2(doStuff)(() => { z = "hi"; }) : void +> : ^^^^ +>recreateImmediate2(doStuff) : (f: () => void) => void +> : ^^^^^^^^^^ ^^^^^^^^^ +>recreateImmediate2 : (f: (...args: A) => R) => (immediate ...args: A) => R +> : ^ ^^^^^^^^^ ^^ ^^ ^^ ^^^^^ +>doStuff : (f: () => void) => void +> : ^ ^^ ^^^^^ +>() => { z = "hi"; } : () => void +> : ^^^^^^^^^^ + + z = "hi"; +>z = "hi" : "hi" +> : ^^^^ +>z : string | number +> : ^^^^^^^^^^^^^^^ +>"hi" : "hi" +> : ^^^^ + + }); + z; // string | number +>z : string | number +> : ^^^^^^^^^^^^^^^ +} + +// Subtype reduction considers (cb: () => void) => a subtype of (immediate cb: () => void) => void + +declare function fa1(cb1: () => void): void; +>fa1 : (cb1: () => void) => void +> : ^ ^^ ^^^^^ +>cb1 : () => void +> : ^^^^^^ + +declare function fa2(immediate cb2: () => void): void; +>fa2 : (cb2: () => void) => void +> : ^ ^^ ^^^^^ +>cb2 : () => void +> : ^^^^^^ + +const fa = Math.random() > 0.5 ? fa1 : fa2; +>fa : (cb2: () => void) => void +> : ^ ^^ ^^^^^ +>Math.random() > 0.5 ? fa1 : fa2 : (cb2: () => void) => void +> : ^ ^^ ^^^^^ +>Math.random() > 0.5 : boolean +> : ^^^^^^^ +>Math.random() : number +> : ^^^^^^ +>Math.random : () => number +> : ^^^^^^ +>Math : Math +> : ^^^^ +>random : () => number +> : ^^^^^^ +>0.5 : 0.5 +> : ^^^ +>fa1 : (cb1: () => void) => void +> : ^ ^^ ^^^^^ +>fa2 : (cb2: () => void) => void +> : ^ ^^ ^^^^^ + +function fta() { +>fta : () => void +> : ^^^^^^^^^^ + + let x: string | number = "OK"; +>x : string | number +> : ^^^^^^^^^^^^^^^ +>"OK" : "OK" +> : ^^^^ + + fa(() => { +>fa(() => { x = 10; }) : void +> : ^^^^ +>fa : (cb2: () => void) => void +> : ^ ^^ ^^^^^ +>() => { x = 10; } : () => void +> : ^^^^^^^^^^ + + x = 10; +>x = 10 : 10 +> : ^^ +>x : string | number +> : ^^^^^^^^^^^^^^^ +>10 : 10 +> : ^^ + + }); + x; // string | number +>x : string | number +> : ^^^^^^^^^^^^^^^ +} + +declare function fb1(cb1: () => void): void; +>fb1 : (cb1: () => void) => void +> : ^ ^^ ^^^^^ +>cb1 : () => void +> : ^^^^^^ + +declare function fb2(immediate cb2: () => void): void; +>fb2 : (cb2: () => void) => void +> : ^ ^^ ^^^^^ +>cb2 : () => void +> : ^^^^^^ + +const fb = Math.random() > 0.5 ? fb2 : fb1; +>fb : (cb2: () => void) => void +> : ^ ^^ ^^^^^ +>Math.random() > 0.5 ? fb2 : fb1 : (cb2: () => void) => void +> : ^ ^^ ^^^^^ +>Math.random() > 0.5 : boolean +> : ^^^^^^^ +>Math.random() : number +> : ^^^^^^ +>Math.random : () => number +> : ^^^^^^ +>Math : Math +> : ^^^^ +>random : () => number +> : ^^^^^^ +>0.5 : 0.5 +> : ^^^ +>fb2 : (cb2: () => void) => void +> : ^ ^^ ^^^^^ +>fb1 : (cb1: () => void) => void +> : ^ ^^ ^^^^^ + +function ftb() { +>ftb : () => void +> : ^^^^^^^^^^ + + let x: string | number = "OK"; +>x : string | number +> : ^^^^^^^^^^^^^^^ +>"OK" : "OK" +> : ^^^^ + + fb(() => { +>fb(() => { x = 10; }) : void +> : ^^^^ +>fb : (cb2: () => void) => void +> : ^ ^^ ^^^^^ +>() => { x = 10; } : () => void +> : ^^^^^^^^^^ + + x = 10; +>x = 10 : 10 +> : ^^ +>x : string | number +> : ^^^^^^^^^^^^^^^ +>10 : 10 +> : ^^ + + }); + x; // string | number +>x : string | number +> : ^^^^^^^^^^^^^^^ +} + +// A union signature parameter is immediate if any underlying parameter in same position is immediate + +declare const fc: ((immediate cb: () => void) => void) | ((cb: () => void) => void); +>fc : ((cb: () => void) => void) | ((cb: () => void) => void) +> : ^^ ^^ ^^^^^ ^^^^^^ ^^ ^^^^^ ^ +>cb : () => void +> : ^^^^^^ +>cb : () => void +> : ^^^^^^ + +function ftc() { +>ftc : () => void +> : ^^^^^^^^^^ + + let x: string | number = "OK"; +>x : string | number +> : ^^^^^^^^^^^^^^^ +>"OK" : "OK" +> : ^^^^ + + fc(() => { +>fc(() => { x = 10; }) : void +> : ^^^^ +>fc : ((cb: () => void) => void) | ((cb: () => void) => void) +> : ^^ ^^ ^^^^^ ^^^^^^ ^^ ^^^^^ ^ +>() => { x = 10; } : () => void +> : ^^^^^^^^^^ + + x = 10; +>x = 10 : 10 +> : ^^ +>x : string | number +> : ^^^^^^^^^^^^^^^ +>10 : 10 +> : ^^ + + }); + x; // string | number +>x : string | number +> : ^^^^^^^^^^^^^^^ +} + +declare const fd: ((cb: () => void) => void) | ((immediate cb: () => void) => void); +>fd : ((cb: () => void) => void) | ((cb: () => void) => void) +> : ^^ ^^ ^^^^^ ^^^^^^ ^^ ^^^^^ ^ +>cb : () => void +> : ^^^^^^ +>cb : () => void +> : ^^^^^^ + +function ftd() { +>ftd : () => void +> : ^^^^^^^^^^ + + let x: string | number = "OK"; +>x : string | number +> : ^^^^^^^^^^^^^^^ +>"OK" : "OK" +> : ^^^^ + + fd(() => { +>fd(() => { x = 10; }) : void +> : ^^^^ +>fd : ((cb: () => void) => void) | ((cb: () => void) => void) +> : ^^ ^^ ^^^^^ ^^^^^^ ^^ ^^^^^ ^ +>() => { x = 10; } : () => void +> : ^^^^^^^^^^ + + x = 10; +>x = 10 : 10 +> : ^^ +>x : string | number +> : ^^^^^^^^^^^^^^^ +>10 : 10 +> : ^^ + + }); + x; // string | number +>x : string | number +> : ^^^^^^^^^^^^^^^ +} + +// https://github.com/microsoft/TypeScript/issues/11498 + +declare function mystery(immediate cb: () => void): void; +>mystery : (cb: () => void) => void +> : ^ ^^ ^^^^^ +>cb : () => void +> : ^^^^^^ + +function fx1() { +>fx1 : () => void +> : ^^^^^^^^^^ + + let x: string | number = "OK"; +>x : string | number +> : ^^^^^^^^^^^^^^^ +>"OK" : "OK" +> : ^^^^ + + x; // string +>x : string +> : ^^^^^^ + + mystery(() => { +>mystery(() => { x = 10; }) : void +> : ^^^^ +>mystery : (cb: () => void) => void +> : ^ ^^ ^^^^^ +>() => { x = 10; } : () => void +> : ^^^^^^^^^^ + + x = 10; +>x = 10 : 10 +> : ^^ +>x : string | number +> : ^^^^^^^^^^^^^^^ +>10 : 10 +> : ^^ + + }); + x; // string | number +>x : string | number +> : ^^^^^^^^^^^^^^^ + + if (x === 10) {} +>x === 10 : boolean +> : ^^^^^^^ +>x : string | number +> : ^^^^^^^^^^^^^^^ +>10 : 10 +> : ^^ +} + +// https://github.com/microsoft/TypeScript/issues/15380 + +class Foo { +>Foo : Foo +> : ^^^ + + public bar: string = ""; +>bar : string +> : ^^^^^^ +>"" : "" +> : ^^ +} + +function fx2() { +>fx2 : () => void +> : ^^^^^^^^^^ + + let foo: Foo | null = null; +>foo : Foo | null +> : ^^^^^^^^^^ + + [1].forEach((item) => { +>[1].forEach((item) => { foo = new Foo(); }) : void +> : ^^^^ +>[1].forEach : (callbackfn: (value: number, index: number, array: number[]) => void, thisArg?: any) => void +> : ^ ^^^ ^^^^^^^^^^ ^^ ^^ ^^^^^^^^^^^^^^^ ^^ ^^^ ^^^^^ +>[1] : number[] +> : ^^^^^^^^ +>1 : 1 +> : ^ +>forEach : (callbackfn: (value: number, index: number, array: number[]) => void, thisArg?: any) => void +> : ^ ^^^ ^^^^^^^^^^ ^^ ^^ ^^^^^^^^^^^^^^^ ^^ ^^^ ^^^^^ +>(item) => { foo = new Foo(); } : (item: number) => void +> : ^ ^^^^^^^^^^^^^^^^^ +>item : number +> : ^^^^^^ + + foo = new Foo(); +>foo = new Foo() : Foo +> : ^^^ +>foo : Foo | null +> : ^^^^^^^^^^ +>new Foo() : Foo +> : ^^^ +>Foo : typeof Foo +> : ^^^^^^^^^^ + + }); + if (foo) { +>foo : Foo | null +> : ^^^^^^^^^^ + + foo.bar; +>foo.bar : string +> : ^^^^^^ +>foo : Foo +> : ^^^ +>bar : string +> : ^^^^^^ + } +} + +// https://github.com/microsoft/TypeScript/issues/57880 + +const call = (immediate f: () => void) => f(); +>call : (f: () => void) => void +> : ^ ^^ ^^^^^^^^^ +>(immediate f: () => void) => f() : (f: () => void) => void +> : ^ ^^ ^^^^^^^^^ +>f : () => void +> : ^^^^^^ +>f() : void +> : ^^^^ +>f : () => void +> : ^^^^^^ + +const fx3 = () => { +>fx3 : () => void +> : ^^^^^^^^^^ +>() => { let a: undefined | number = undefined; call(() => { a = 1; }); if (a !== undefined) { a.toString(); }} : () => void +> : ^^^^^^^^^^ + + let a: undefined | number = undefined; +>a : number | undefined +> : ^^^^^^^^^^^^^^^^^^ +>undefined : undefined +> : ^^^^^^^^^ + + call(() => { a = 1; }); +>call(() => { a = 1; }) : void +> : ^^^^ +>call : (f: () => void) => void +> : ^ ^^ ^^^^^^^^^ +>() => { a = 1; } : () => void +> : ^^^^^^^^^^ +>a = 1 : 1 +> : ^ +>a : number | undefined +> : ^^^^^^^^^^^^^^^^^^ +>1 : 1 +> : ^ + + if (a !== undefined) { +>a !== undefined : boolean +> : ^^^^^^^ +>a : number | undefined +> : ^^^^^^^^^^^^^^^^^^ +>undefined : undefined +> : ^^^^^^^^^ + + a.toString(); +>a.toString() : string +> : ^^^^^^ +>a.toString : (radix?: number) => string +> : ^ ^^^ ^^^^^ +>a : number +> : ^^^^^^ +>toString : (radix?: number) => string +> : ^ ^^^ ^^^^^ + } +}; + +// https://github.com/microsoft/TypeScript/issues/58291 + +async function execute(immediate onError: (_err: Error | undefined) => void) { +>execute : (onError: (_err: Error | undefined) => void) => Promise +> : ^ ^^ ^^^^^^^^^^^^^^^^^^ +>onError : (_err: Error | undefined) => void +> : ^ ^^ ^^^^^ +>_err : Error | undefined +> : ^^^^^^^^^^^^^^^^^ + + onError(new Error("a")); +>onError(new Error("a")) : void +> : ^^^^ +>onError : (_err: Error | undefined) => void +> : ^ ^^ ^^^^^ +>new Error("a") : Error +> : ^^^^^ +>Error : ErrorConstructor +> : ^^^^^^^^^^^^^^^^ +>"a" : "a" +> : ^^^ +} + +async function run() { +>run : () => Promise +> : ^^^^^^^^^^^^^^^^^^^^^^ + + let result: boolean = true; +>result : boolean +> : ^^^^^^^ +>true : true +> : ^^^^ + + await execute(() => { +>await execute(() => { result = false; }) : void +> : ^^^^ +>execute(() => { result = false; }) : Promise +> : ^^^^^^^^^^^^^ +>execute : (onError: (_err: Error | undefined) => void) => Promise +> : ^ ^^ ^^^^^^^^^^^^^^^^^^ +>() => { result = false; } : () => void +> : ^^^^^^^^^^ + + result = false; +>result = false : false +> : ^^^^^ +>result : boolean +> : ^^^^^^^ +>false : false +> : ^^^^^ + + }); + if (result === false) { +>result === false : boolean +> : ^^^^^^^ +>result : boolean +> : ^^^^^^^ +>false : false +> : ^^^^^ + + console.log("error"); +>console.log("error") : void +> : ^^^^ +>console.log : (...data: any[]) => void +> : ^^^^ ^^ ^^^^^ +>console : Console +> : ^^^^^^^ +>log : (...data: any[]) => void +> : ^^^^ ^^ ^^^^^ +>"error" : "error" +> : ^^^^^^^ + } + return result; +>result : boolean +> : ^^^^^^^ +} + diff --git a/tests/cases/compiler/immediateCallbacks.ts b/tests/cases/compiler/immediateCallbacks.ts new file mode 100644 index 0000000000000..d2bb257c8d3f5 --- /dev/null +++ b/tests/cases/compiler/immediateCallbacks.ts @@ -0,0 +1,288 @@ +// @strict: true +// @noemit: true +// @target: esnext + +declare function deferred(cb: () => void): void; +declare function immediate1(immediate cb: () => void): void; +declare function immediate2(/** @immediate */ cb: () => void): void; +declare function immediate3(/** @immediate */ immediate cb: () => void): void; + +function f01() { + let x: string | number = "OK"; + deferred(() => { + x = 42; + }); + x; // string +} + +function f02() { + let x: string | number = "OK"; + immediate1(() => { + x = 42; + }); + x; // string | number +} + +function f03() { + let x: string | number = "OK"; + immediate2(() => { + x = 42; + }); + x; // string | number +} + +function f04() { + let x: string | number = "OK"; + immediate3(() => { + x = 42; + }); + x; // string | number +} + +// Parameter is considered immediate if one or more overloads include the modifier in that parameter position + +declare function overloaded(cb: (x: T) => T): void; +declare function overloaded(cb: (x: T, y: T) => T): void; +declare function overloaded(immediate cb: (...args: any) => any): void; + +function f05() { + let x: string | number = "OK"; + overloaded(() => { + x = 42; + }); + x; // string | number +} + +// immediate is permitted on a rest parameter + +declare function invokeDeferred(...args: ((...args: any) => any)[]): void; +declare function invokeImmediate(immediate ...args: ((...args: any) => any)[]): void; + +function f06() { + let a = []; + a.push("abc"); + a; // string[] + invokeImmediate( + () => { + a; // string[] + a.push(42); + a; // (string | number)[] + }, + () => { + a; // string[] + a.push(true); + a; // (string | boolean)[] + } + ); + a; // (string | number | boolean)[] +} + +function f07() { + let a = []; + a.push("abc"); + a; // string[] + invokeDeferred( + () => { + a; // string[] + a.push(42); + a; // (string | number)[] + }, + () => { + a; // string[] + a.push(true); + a; // (string | boolean)[] + } + ); + a; // string[] +} + +// immediate modifier must precede public/private/protected/readonly + +class CC { + constructor(immediate public readonly x: () => void) {} +} + +// immediate requires parameter to have type that permits functions + +declare function f10(immediate f: () => void): void; +declare function f11(immediate f: Function): void; +declare function f12(immediate f: any): void; +declare function f13(immediate f: object): void; +declare function f14(immediate f: {}): void; +declare function f15(immediate f: unknown): void; +declare function f16(immediate f: T): void; +declare function f17 any>(immediate f: T): void; +declare function f18 void)>(immediate f: T): void; + +declare function f20(immediate ...funcs: Function[]): void; +declare function f21 any)[]>(immediate ...funcs: T): void; +declare function f22 void))[]>(immediate ...funcs: T): void; +declare function f23 void)[]>(immediate ...funcs: T): void; +declare function f24 void)[]>(immediate ...funcs: T | string[]): void; + +declare function f30(immediate f: { foo(): void }): void; +declare function f31(immediate f: number): void; +declare function f32(immediate ...funcs: number[]): void; + +type T10 = (immediate f: () => void) => void; +type T11 = (immediate f: { (): void }) => void; +type T12 = (immediate f: Function) => void; +type T13 = (immediate f: any) => void; + +type T20 = (immediate f: { foo(): void }) => void; +type T21 = (immediate f: number) => void; +type T22 = (immediate ...funcs: number[]) => void; +type T23 = { immediate x: () => void }; + +// immediate modifier is not captured in argument list tuples + +declare function doStuff(immediate f: () => void): void; + +declare function recreate(f: (...args: A) => R): (...args: A) => R; +declare function recreateImmediate1(f: (immediate ...args: A) => R): (...args: A) => R; +declare function recreateImmediate2(f: (...args: A) => R): (immediate ...args: A) => R; + +function ff1() { + let x: string | number; + x = 123; + doStuff(() => { + x = "hi"; + }); + x; // string | number +} + +function ff2() { + let y: string | number; + y = 123; + recreate(doStuff)(() => { + y = "hi"; + }); + y; // number +} + +function ff3() { + let z: string | number; + z = 123; + recreateImmediate1(doStuff)(() => { + z = "hi"; + }); + z; // number +} + +function ff4() { + let z: string | number; + z = 123; + recreateImmediate2(doStuff)(() => { + z = "hi"; + }); + z; // string | number +} + +// Subtype reduction considers (cb: () => void) => a subtype of (immediate cb: () => void) => void + +declare function fa1(cb1: () => void): void; +declare function fa2(immediate cb2: () => void): void; + +const fa = Math.random() > 0.5 ? fa1 : fa2; + +function fta() { + let x: string | number = "OK"; + fa(() => { + x = 10; + }); + x; // string | number +} + +declare function fb1(cb1: () => void): void; +declare function fb2(immediate cb2: () => void): void; + +const fb = Math.random() > 0.5 ? fb2 : fb1; + +function ftb() { + let x: string | number = "OK"; + fb(() => { + x = 10; + }); + x; // string | number +} + +// A union signature parameter is immediate if any underlying parameter in same position is immediate + +declare const fc: ((immediate cb: () => void) => void) | ((cb: () => void) => void); + +function ftc() { + let x: string | number = "OK"; + fc(() => { + x = 10; + }); + x; // string | number +} + +declare const fd: ((cb: () => void) => void) | ((immediate cb: () => void) => void); + +function ftd() { + let x: string | number = "OK"; + fd(() => { + x = 10; + }); + x; // string | number +} + +// https://github.com/microsoft/TypeScript/issues/11498 + +declare function mystery(immediate cb: () => void): void; + +function fx1() { + let x: string | number = "OK"; + x; // string + mystery(() => { + x = 10; + }); + x; // string | number + if (x === 10) {} +} + +// https://github.com/microsoft/TypeScript/issues/15380 + +class Foo { + public bar: string = ""; +} + +function fx2() { + let foo: Foo | null = null; + [1].forEach((item) => { + foo = new Foo(); + }); + if (foo) { + foo.bar; + } +} + +// https://github.com/microsoft/TypeScript/issues/57880 + +const call = (immediate f: () => void) => f(); + +const fx3 = () => { + let a: undefined | number = undefined; + call(() => { a = 1; }); + if (a !== undefined) { + a.toString(); + } +}; + +// https://github.com/microsoft/TypeScript/issues/58291 + +async function execute(immediate onError: (_err: Error | undefined) => void) { + onError(new Error("a")); +} + +async function run() { + let result: boolean = true; + await execute(() => { + result = false; + }); + if (result === false) { + console.log("error"); + } + return result; +}