diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index d22c2087a3a..6cf611df37e 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -3763,8 +3763,8 @@ declare namespace ts { BooleanKeyword = 136, ConstructorKeyword = 137, DeclareKeyword = 138, - DeferredKeyword = 139, - GetKeyword = 140, + GetKeyword = 139, + ImmediateKeyword = 140, InferKeyword = 141, IntrinsicKeyword = 142, IsKeyword = 143, @@ -3961,7 +3961,7 @@ declare namespace ts { JSDocImplementsTag = 330, JSDocAuthorTag = 331, JSDocDeprecatedTag = 332, - JSDocDeferredTag = 333, + JSDocImmediateTag = 333, JSDocClassTag = 334, JSDocPublicTag = 335, JSDocPrivateTag = 336, @@ -4106,7 +4106,6 @@ declare namespace ts { | SyntaxKind.DebuggerKeyword | SyntaxKind.DeclareKeyword | SyntaxKind.DefaultKeyword - | SyntaxKind.DeferredKeyword | SyntaxKind.DeleteKeyword | SyntaxKind.DoKeyword | SyntaxKind.ElseKeyword @@ -4121,6 +4120,7 @@ declare namespace ts { | SyntaxKind.GetKeyword | SyntaxKind.GlobalKeyword | SyntaxKind.IfKeyword + | SyntaxKind.ImmediateKeyword | SyntaxKind.ImplementsKeyword | SyntaxKind.ImportKeyword | SyntaxKind.InferKeyword @@ -4170,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.DeferredKeyword | 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; @@ -4227,9 +4227,9 @@ declare namespace ts { In = 8192, Out = 16384, Decorator = 32768, - Deferred = 65536, + Immediate = 65536, Deprecated = 131072, - JSDocDeferred = 262144, + JSDocImmediate = 262144, HasComputedJSDocModifiers = 268435456, HasComputedFlags = 536870912, AccessibilityModifier = 7, @@ -4387,8 +4387,8 @@ declare namespace ts { type ConstKeyword = ModifierToken; type DeclareKeyword = ModifierToken; type DefaultKeyword = ModifierToken; - type DeferredKeyword = ModifierToken; type ExportKeyword = ModifierToken; + type ImmediateKeyword = ModifierToken; type InKeyword = ModifierToken; type PrivateKeyword = ModifierToken; type ProtectedKeyword = ModifierToken; @@ -4397,7 +4397,7 @@ declare namespace ts { type OutKeyword = ModifierToken; type OverrideKeyword = ModifierToken; type StaticKeyword = ModifierToken; - type Modifier = AbstractKeyword | AccessorKeyword | AsyncKeyword | ConstKeyword | DeclareKeyword | DefaultKeyword | DeferredKeyword | 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; @@ -5727,8 +5727,8 @@ declare namespace ts { interface JSDocDeprecatedTag extends JSDocTag { kind: SyntaxKind.JSDocDeprecatedTag; } - interface JSDocDeferredTag extends JSDocTag { - kind: SyntaxKind.JSDocDeferredTag; + interface JSDocImmediateTag extends JSDocTag { + kind: SyntaxKind.JSDocImmediateTag; } interface JSDocClassTag extends JSDocTag { readonly kind: SyntaxKind.JSDocClassTag; @@ -7745,8 +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; - createJSDocDeferredTag(tagName: Identifier | undefined, comment?: string | NodeArray): JSDocDeferredTag; - updateJSDocDeferredTag(node: JSDocDeferredTag, tagName: Identifier | undefined, comment?: string | NodeArray): JSDocDeferredTag; + 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; @@ -8600,8 +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 deferred tag for the node if present */ - function getJSDocDeferredTag(node: Node): JSDocDeferredTag | 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 */ @@ -9046,7 +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 isJSDocDeferredTag(node: Node): node is JSDocDeferredTag; + 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 1dc5b63951e..aea831a5590 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/goToTypeDefinition_promiseType.baseline.jsonc b/tests/baselines/reference/goToTypeDefinition_promiseType.baseline.jsonc index f39b30067fc..f84caf2e462 100644 --- a/tests/baselines/reference/goToTypeDefinition_promiseType.baseline.jsonc +++ b/tests/baselines/reference/goToTypeDefinition_promiseType.baseline.jsonc @@ -19,14 +19,14 @@ // * @param onrejected The callback to execute when the Promise is rejected. // * @returns A Promise for the completion of which ever callback is executed. // */ -// then(/** @deferred */ onfulfilled?: ((value: T) => TResult1 | PromiseLike) | undefined | null, /** @deferred */ onrejected?: ((reason: any) => TResult2 | PromiseLike) | undefined | null): Promise; +// then(onfulfilled?: ((value: T) => TResult1 | PromiseLike) | undefined | null, onrejected?: ((reason: any) => TResult2 | PromiseLike) | undefined | null): Promise; // // /** // * Attaches a callback for only the rejection of the Promise. // * @param onrejected The callback to execute when the Promise is rejected. // * @returns A Promise for the completion of the callback. // */ -// catch(/** @deferred */ onrejected?: ((reason: any) => TResult | PromiseLike) | undefined | null): Promise; +// catch(onrejected?: ((reason: any) => TResult | PromiseLike) | undefined | null): Promise; // }|> // // /** @@ -80,14 +80,14 @@ // * @param onrejected The callback to execute when the Promise is rejected. // * @returns A Promise for the completion of which ever callback is executed. // */ -// then(/** @deferred */ onfulfilled?: ((value: T) => TResult1 | PromiseLike) | undefined | null, /** @deferred */ onrejected?: ((reason: any) => TResult2 | PromiseLike) | undefined | null): Promise; +// then(onfulfilled?: ((value: T) => TResult1 | PromiseLike) | undefined | null, onrejected?: ((reason: any) => TResult2 | PromiseLike) | undefined | null): Promise; // // /** // * Attaches a callback for only the rejection of the Promise. // * @param onrejected The callback to execute when the Promise is rejected. // * @returns A Promise for the completion of the callback. // */ -// catch(/** @deferred */ onrejected?: ((reason: any) => TResult | PromiseLike) | undefined | null): Promise; +// catch(onrejected?: ((reason: any) => TResult | PromiseLike) | undefined | null): Promise; // }|> // // /** diff --git a/tests/baselines/reference/immediateCallbacks.errors.txt b/tests/baselines/reference/immediateCallbacks.errors.txt new file mode 100644 index 00000000000..2d2f7233083 --- /dev/null +++ b/tests/baselines/reference/immediateCallbacks.errors.txt @@ -0,0 +1,259 @@ +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 + } + + // 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 00000000000..6c80081e718 --- /dev/null +++ b/tests/baselines/reference/immediateCallbacks.symbols @@ -0,0 +1,625 @@ +//// [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)) +} + +// https://github.com/microsoft/TypeScript/issues/11498 + +declare function mystery(immediate cb: () => void): void; +>mystery : Symbol(mystery, Decl(immediateCallbacks.ts, 174, 1)) +>cb : Symbol(cb, Decl(immediateCallbacks.ts, 178, 25)) + +function fx1() { +>fx1 : Symbol(fx1, Decl(immediateCallbacks.ts, 178, 57)) + + let x: string | number = "OK"; +>x : Symbol(x, Decl(immediateCallbacks.ts, 181, 7)) + + x; // string +>x : Symbol(x, Decl(immediateCallbacks.ts, 181, 7)) + + mystery(() => { +>mystery : Symbol(mystery, Decl(immediateCallbacks.ts, 174, 1)) + + x = 10; +>x : Symbol(x, Decl(immediateCallbacks.ts, 181, 7)) + + }); + x; // string | number +>x : Symbol(x, Decl(immediateCallbacks.ts, 181, 7)) + + if (x === 10) {} +>x : Symbol(x, Decl(immediateCallbacks.ts, 181, 7)) +} + +// https://github.com/microsoft/TypeScript/issues/15380 + +class Foo { +>Foo : Symbol(Foo, Decl(immediateCallbacks.ts, 188, 1)) + + public bar: string = ""; +>bar : Symbol(Foo.bar, Decl(immediateCallbacks.ts, 192, 11)) +} + +function fx2() { +>fx2 : Symbol(fx2, Decl(immediateCallbacks.ts, 194, 1)) + + let foo: Foo | null = null; +>foo : Symbol(foo, Decl(immediateCallbacks.ts, 197, 5)) +>Foo : Symbol(Foo, Decl(immediateCallbacks.ts, 188, 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, 198, 15)) + + foo = new Foo(); +>foo : Symbol(foo, Decl(immediateCallbacks.ts, 197, 5)) +>Foo : Symbol(Foo, Decl(immediateCallbacks.ts, 188, 1)) + + }); + if (foo) { +>foo : Symbol(foo, Decl(immediateCallbacks.ts, 197, 5)) + + foo.bar; +>foo.bar : Symbol(Foo.bar, Decl(immediateCallbacks.ts, 192, 11)) +>foo : Symbol(foo, Decl(immediateCallbacks.ts, 197, 5)) +>bar : Symbol(Foo.bar, Decl(immediateCallbacks.ts, 192, 11)) + } +} + +// https://github.com/microsoft/TypeScript/issues/57880 + +const call = (immediate f: () => void) => f(); +>call : Symbol(call, Decl(immediateCallbacks.ts, 208, 5)) +>f : Symbol(f, Decl(immediateCallbacks.ts, 208, 14)) +>f : Symbol(f, Decl(immediateCallbacks.ts, 208, 14)) + +const fx3 = () => { +>fx3 : Symbol(fx3, Decl(immediateCallbacks.ts, 210, 5)) + + let a: undefined | number = undefined; +>a : Symbol(a, Decl(immediateCallbacks.ts, 211, 7)) +>undefined : Symbol(undefined) + + call(() => { a = 1; }); +>call : Symbol(call, Decl(immediateCallbacks.ts, 208, 5)) +>a : Symbol(a, Decl(immediateCallbacks.ts, 211, 7)) + + if (a !== undefined) { +>a : Symbol(a, Decl(immediateCallbacks.ts, 211, 7)) +>undefined : Symbol(undefined) + + a.toString(); +>a.toString : Symbol(Number.toString, Decl(lib.es5.d.ts, --, --)) +>a : Symbol(a, Decl(immediateCallbacks.ts, 211, 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, 216, 2)) +>onError : Symbol(onError, Decl(immediateCallbacks.ts, 220, 23)) +>_err : Symbol(_err, Decl(immediateCallbacks.ts, 220, 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, 220, 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, 222, 1)) + + let result: boolean = true; +>result : Symbol(result, Decl(immediateCallbacks.ts, 225, 7)) + + await execute(() => { +>execute : Symbol(execute, Decl(immediateCallbacks.ts, 216, 2)) + + result = false; +>result : Symbol(result, Decl(immediateCallbacks.ts, 225, 7)) + + }); + if (result === false) { +>result : Symbol(result, Decl(immediateCallbacks.ts, 225, 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, 225, 7)) +} + diff --git a/tests/baselines/reference/immediateCallbacks.types b/tests/baselines/reference/immediateCallbacks.types new file mode 100644 index 00000000000..43d2021c6e5 --- /dev/null +++ b/tests/baselines/reference/immediateCallbacks.types @@ -0,0 +1,1031 @@ +//// [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 +> : ^^^^^^^^^^^^^^^ +} + +// 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/baselines/reference/parserharness.types b/tests/baselines/reference/parserharness.types index 8bc16b33edf..0326d8453ba 100644 --- a/tests/baselines/reference/parserharness.types +++ b/tests/baselines/reference/parserharness.types @@ -1838,8 +1838,8 @@ module Harness { }); return isAsync; ->isAsync : boolean -> : ^^^^^^^ +>isAsync : true +> : ^^^^ } } catch (e) { diff --git a/tests/baselines/reference/parserindenter.types b/tests/baselines/reference/parserindenter.types index 02d35ccb265..0d93f460d18 100644 --- a/tests/baselines/reference/parserindenter.types +++ b/tests/baselines/reference/parserindenter.types @@ -2328,8 +2328,8 @@ module Formatting { }); return result; ->result : boolean -> : ^^^^^^^ +>result : true +> : ^^^^ } return false;