From e7fab028109b35fbda59aa3742b868bc6a49bcb7 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Thu, 19 Jan 2023 08:40:58 -0800 Subject: [PATCH 1/3] Revert "Add undefined to JSON.stringify return type (#51897)" This reverts commit c7f49bceed878d751701f018d066fffc5926e3b0. --- src/lib/es5.d.ts | 7 --- .../controlFlowPropertyDeclarations.symbols | 4 +- .../controlFlowPropertyDeclarations.types | 4 +- ...itializerContextualTypeFromContext.symbols | 4 +- ...InitializerContextualTypeFromContext.types | 4 +- ...tructuringParameterDeclaration4.errors.txt | 2 +- .../reference/destructuringTuple.errors.txt | 4 +- .../duplicateNumericIndexers.errors.txt | 2 +- tests/baselines/reference/json.stringify.js | 8 +--- .../reference/json.stringify.symbols | 47 +++++++------------ .../baselines/reference/json.stringify.types | 46 +++++------------- ...ithAsClauseAndLateBoundProperty.errors.txt | 2 +- .../baselines/reference/parserharness.symbols | 4 +- tests/baselines/reference/parserharness.types | 4 +- .../reference/promisePermutations.errors.txt | 2 +- .../reference/promisePermutations2.errors.txt | 2 +- .../reference/promisePermutations3.errors.txt | 4 +- .../reference/redefineArray.errors.txt | 2 +- ...ousTypeNotReferencingTypeParameter.symbols | 4 +- ...ymousTypeNotReferencingTypeParameter.types | 4 +- tests/cases/compiler/json.stringify.ts | 5 +- 21 files changed, 59 insertions(+), 106 deletions(-) diff --git a/src/lib/es5.d.ts b/src/lib/es5.d.ts index e3526d0e6b0bb..9ed6d1c8a0c56 100644 --- a/src/lib/es5.d.ts +++ b/src/lib/es5.d.ts @@ -1117,13 +1117,6 @@ interface JSON { * 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; - /** - * 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 An array of strings and numbers that acts as an approved list for selecting the object properties that will be stringified. - * @param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read. - */ - stringify(value: Function | Symbol | undefined, replacer?: (number | string)[] | null, space?: string | number): undefined; /** * Converts a JavaScript value to a JavaScript Object Notation (JSON) string. * @param value A JavaScript value, usually an object or array, to be converted. diff --git a/tests/baselines/reference/controlFlowPropertyDeclarations.symbols b/tests/baselines/reference/controlFlowPropertyDeclarations.symbols index 62786b759984f..a4b343f9ccbe1 100644 --- a/tests/baselines/reference/controlFlowPropertyDeclarations.symbols +++ b/tests/baselines/reference/controlFlowPropertyDeclarations.symbols @@ -232,9 +232,9 @@ export class HTMLtoJSX { >whitespace : Symbol(whitespace, Decl(controlFlowPropertyDeclarations.ts, 121, 50)) return '{' + JSON.stringify(whitespace) + '}'; ->JSON.stringify : Symbol(JSON.stringify, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>JSON.stringify : Symbol(JSON.stringify, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >JSON : Symbol(JSON, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) ->stringify : Symbol(JSON.stringify, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>stringify : Symbol(JSON.stringify, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >whitespace : Symbol(whitespace, Decl(controlFlowPropertyDeclarations.ts, 121, 50)) }); diff --git a/tests/baselines/reference/controlFlowPropertyDeclarations.types b/tests/baselines/reference/controlFlowPropertyDeclarations.types index 45b6224fc6e70..d1b74c8feb7bf 100644 --- a/tests/baselines/reference/controlFlowPropertyDeclarations.types +++ b/tests/baselines/reference/controlFlowPropertyDeclarations.types @@ -316,9 +316,9 @@ export class HTMLtoJSX { >'{' + JSON.stringify(whitespace) : string >'{' : "{" >JSON.stringify(whitespace) : string ->JSON.stringify : { (value: Function | Symbol, replacer?: (string | number)[], space?: string | number): undefined; (value: any, replacer?: (this: any, key: string, value: any) => any, space?: string | number): string; (value: any, replacer?: (string | number)[], space?: string | number): string; } +>JSON.stringify : { (value: any, replacer?: (this: any, key: string, value: any) => any, space?: string | number): string; (value: any, replacer?: (string | number)[], space?: string | number): string; } >JSON : JSON ->stringify : { (value: Function | Symbol, replacer?: (string | number)[], space?: string | number): undefined; (value: any, replacer?: (this: any, key: string, value: any) => any, space?: string | number): string; (value: any, replacer?: (string | number)[], space?: string | number): string; } +>stringify : { (value: any, replacer?: (this: any, key: string, value: any) => any, space?: string | number): string; (value: any, replacer?: (string | number)[], space?: string | number): string; } >whitespace : string >'}' : "}" diff --git a/tests/baselines/reference/destructuringInitializerContextualTypeFromContext.symbols b/tests/baselines/reference/destructuringInitializerContextualTypeFromContext.symbols index b9710877ef8ac..8ae1b56e20fe7 100644 --- a/tests/baselines/reference/destructuringInitializerContextualTypeFromContext.symbols +++ b/tests/baselines/reference/destructuringInitializerContextualTypeFromContext.symbols @@ -51,9 +51,9 @@ const Child: SFC = ({ }) => `name: ${name} props: ${JSON.stringify(props)}`; >name : Symbol(name, Decl(destructuringInitializerContextualTypeFromContext.ts, 15, 13)) ->JSON.stringify : Symbol(JSON.stringify, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>JSON.stringify : Symbol(JSON.stringify, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >JSON : Symbol(JSON, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) ->stringify : Symbol(JSON.stringify, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>stringify : Symbol(JSON.stringify, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >props : Symbol(props, Decl(destructuringInitializerContextualTypeFromContext.ts, 16, 21)) // Repro from #29189 diff --git a/tests/baselines/reference/destructuringInitializerContextualTypeFromContext.types b/tests/baselines/reference/destructuringInitializerContextualTypeFromContext.types index cbdffc0642b19..d0ddb4918a034 100644 --- a/tests/baselines/reference/destructuringInitializerContextualTypeFromContext.types +++ b/tests/baselines/reference/destructuringInitializerContextualTypeFromContext.types @@ -50,9 +50,9 @@ const Child: SFC = ({ >`name: ${name} props: ${JSON.stringify(props)}` : string >name : "Apollo" | "Artemis" | "Dionysus" | "Persephone" >JSON.stringify(props) : string ->JSON.stringify : { (value: Function | Symbol | undefined, replacer?: (string | number)[] | null | undefined, space?: string | number | undefined): undefined; (value: any, replacer?: ((this: any, key: string, value: any) => any) | undefined, space?: string | number | undefined): string; (value: any, replacer?: (string | number)[] | null | undefined, space?: string | number | undefined): string; } +>JSON.stringify : { (value: any, replacer?: ((this: any, key: string, value: any) => any) | undefined, space?: string | number | undefined): string; (value: any, replacer?: (string | number)[] | null | undefined, space?: string | number | undefined): string; } >JSON : JSON ->stringify : { (value: Function | Symbol | undefined, replacer?: (string | number)[] | null | undefined, space?: string | number | undefined): undefined; (value: any, replacer?: ((this: any, key: string, value: any) => any) | undefined, space?: string | number | undefined): string; (value: any, replacer?: (string | number)[] | null | undefined, space?: string | number | undefined): string; } +>stringify : { (value: any, replacer?: ((this: any, key: string, value: any) => any) | undefined, space?: string | number | undefined): string; (value: any, replacer?: (string | number)[] | null | undefined, space?: string | number | undefined): string; } >props : {} // Repro from #29189 diff --git a/tests/baselines/reference/destructuringParameterDeclaration4.errors.txt b/tests/baselines/reference/destructuringParameterDeclaration4.errors.txt index 67c7783cc75c1..c8f9fd6b305e7 100644 --- a/tests/baselines/reference/destructuringParameterDeclaration4.errors.txt +++ b/tests/baselines/reference/destructuringParameterDeclaration4.errors.txt @@ -41,7 +41,7 @@ tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts( a1(...array2); // Error parameter type is (number|string)[] ~~~~~~ !!! error TS2552: Cannot find name 'array2'. Did you mean 'Array'? -!!! related TS2728 /.ts/lib.es5.d.ts:1502:13: 'Array' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:1495:13: 'Array' is declared here. a5([1, 2, "string", false, true]); // Error, parameter type is [any, any, [[any]]] ~~~~~~~~ !!! error TS2322: Type 'string' is not assignable to type '[[any]]'. diff --git a/tests/baselines/reference/destructuringTuple.errors.txt b/tests/baselines/reference/destructuringTuple.errors.txt index d5991c4805f6a..20d9a290c04c9 100644 --- a/tests/baselines/reference/destructuringTuple.errors.txt +++ b/tests/baselines/reference/destructuringTuple.errors.txt @@ -33,8 +33,8 @@ tests/cases/compiler/destructuringTuple.ts(11,60): error TS2769: No overload mat !!! error TS2769: Overload 2 of 3, '(callbackfn: (previousValue: [], currentValue: number, currentIndex: number, array: number[]) => [], initialValue: []): []', gave the following error. !!! error TS2769: Type 'never[]' is not assignable to type '[]'. !!! error TS2769: Target allows only 0 element(s) but source may have more. -!!! related TS6502 /.ts/lib.es5.d.ts:1467:24: The expected type comes from the return type of this signature. -!!! related TS6502 /.ts/lib.es5.d.ts:1473:27: The expected type comes from the return type of this signature. +!!! related TS6502 /.ts/lib.es5.d.ts:1460:24: The expected type comes from the return type of this signature. +!!! related TS6502 /.ts/lib.es5.d.ts:1466:27: The expected type comes from the return type of this signature. ~~ !!! error TS2769: No overload matches this call. !!! error TS2769: Overload 1 of 2, '(...items: ConcatArray[]): never[]', gave the following error. diff --git a/tests/baselines/reference/duplicateNumericIndexers.errors.txt b/tests/baselines/reference/duplicateNumericIndexers.errors.txt index 9121289c5ef08..c34d35766c139 100644 --- a/tests/baselines/reference/duplicateNumericIndexers.errors.txt +++ b/tests/baselines/reference/duplicateNumericIndexers.errors.txt @@ -11,7 +11,7 @@ tests/cases/conformance/types/members/duplicateNumericIndexers.ts(25,5): error T tests/cases/conformance/types/members/duplicateNumericIndexers.ts(29,5): error TS2374: Duplicate index signature for type 'number'. tests/cases/conformance/types/members/duplicateNumericIndexers.ts(30,5): error TS2374: Duplicate index signature for type 'number'. lib.es5.d.ts(517,5): error TS2374: Duplicate index signature for type 'number'. -lib.es5.d.ts(1488,5): error TS2374: Duplicate index signature for type 'number'. +lib.es5.d.ts(1481,5): error TS2374: Duplicate index signature for type 'number'. ==== tests/cases/conformance/types/members/duplicateNumericIndexers.ts (12 errors) ==== diff --git a/tests/baselines/reference/json.stringify.js b/tests/baselines/reference/json.stringify.js index 7eeea65139b21..a37485bdfa28d 100644 --- a/tests/baselines/reference/json.stringify.js +++ b/tests/baselines/reference/json.stringify.js @@ -4,9 +4,7 @@ JSON.stringify(value, undefined, 2); JSON.stringify(value, null, 2); JSON.stringify(value, ["a", 1], 2); JSON.stringify(value, (k) => undefined, 2); -JSON.stringify(() => {}, undefined, 2); -JSON.stringify(Symbol('s'), undefined, 2); -JSON.stringify(undefined, undefined, 2); +JSON.stringify(value, undefined, 2); //// [json.stringify.js] var value = null; @@ -14,6 +12,4 @@ JSON.stringify(value, undefined, 2); JSON.stringify(value, null, 2); JSON.stringify(value, ["a", 1], 2); JSON.stringify(value, function (k) { return undefined; }, 2); -JSON.stringify(function () { }, undefined, 2); -JSON.stringify(Symbol('s'), undefined, 2); -JSON.stringify(undefined, undefined, 2); +JSON.stringify(value, undefined, 2); diff --git a/tests/baselines/reference/json.stringify.symbols b/tests/baselines/reference/json.stringify.symbols index 3f0c17e147181..213e4a0e28ad3 100644 --- a/tests/baselines/reference/json.stringify.symbols +++ b/tests/baselines/reference/json.stringify.symbols @@ -3,49 +3,36 @@ var value = null; >value : Symbol(value, Decl(json.stringify.ts, 0, 3)) JSON.stringify(value, undefined, 2); ->JSON.stringify : Symbol(JSON.stringify, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) ->JSON : Symbol(JSON, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) ->stringify : Symbol(JSON.stringify, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>JSON.stringify : Symbol(JSON.stringify, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>JSON : Symbol(JSON, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>stringify : Symbol(JSON.stringify, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >value : Symbol(value, Decl(json.stringify.ts, 0, 3)) >undefined : Symbol(undefined) JSON.stringify(value, null, 2); ->JSON.stringify : Symbol(JSON.stringify, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) ->JSON : Symbol(JSON, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) ->stringify : Symbol(JSON.stringify, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>JSON.stringify : Symbol(JSON.stringify, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>JSON : Symbol(JSON, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>stringify : Symbol(JSON.stringify, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >value : Symbol(value, Decl(json.stringify.ts, 0, 3)) JSON.stringify(value, ["a", 1], 2); ->JSON.stringify : Symbol(JSON.stringify, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) ->JSON : Symbol(JSON, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) ->stringify : Symbol(JSON.stringify, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>JSON.stringify : Symbol(JSON.stringify, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>JSON : Symbol(JSON, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>stringify : Symbol(JSON.stringify, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >value : Symbol(value, Decl(json.stringify.ts, 0, 3)) JSON.stringify(value, (k) => undefined, 2); ->JSON.stringify : Symbol(JSON.stringify, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) ->JSON : Symbol(JSON, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) ->stringify : Symbol(JSON.stringify, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>JSON.stringify : Symbol(JSON.stringify, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>JSON : Symbol(JSON, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>stringify : Symbol(JSON.stringify, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >value : Symbol(value, Decl(json.stringify.ts, 0, 3)) >k : Symbol(k, Decl(json.stringify.ts, 4, 23)) >undefined : Symbol(undefined) -JSON.stringify(() => {}, undefined, 2); ->JSON.stringify : Symbol(JSON.stringify, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) ->JSON : Symbol(JSON, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) ->stringify : Symbol(JSON.stringify, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) ->undefined : Symbol(undefined) - -JSON.stringify(Symbol('s'), undefined, 2); ->JSON.stringify : Symbol(JSON.stringify, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) ->JSON : Symbol(JSON, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) ->stringify : Symbol(JSON.stringify, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) ->Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) ->undefined : Symbol(undefined) - -JSON.stringify(undefined, undefined, 2); ->JSON.stringify : Symbol(JSON.stringify, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) ->JSON : Symbol(JSON, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) ->stringify : Symbol(JSON.stringify, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) ->undefined : Symbol(undefined) +JSON.stringify(value, undefined, 2); +>JSON.stringify : Symbol(JSON.stringify, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>JSON : Symbol(JSON, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>stringify : Symbol(JSON.stringify, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>value : Symbol(value, Decl(json.stringify.ts, 0, 3)) >undefined : Symbol(undefined) diff --git a/tests/baselines/reference/json.stringify.types b/tests/baselines/reference/json.stringify.types index 5c209648890cd..44f7636d46afc 100644 --- a/tests/baselines/reference/json.stringify.types +++ b/tests/baselines/reference/json.stringify.types @@ -5,27 +5,27 @@ var value = null; JSON.stringify(value, undefined, 2); >JSON.stringify(value, undefined, 2) : string ->JSON.stringify : { (value: Function | Symbol | undefined, replacer?: (string | number)[] | null | undefined, space?: string | number | undefined): undefined; (value: any, replacer?: ((this: any, key: string, value: any) => any) | undefined, space?: string | number | undefined): string; (value: any, replacer?: (string | number)[] | null | undefined, space?: string | number | undefined): string; } +>JSON.stringify : { (value: any, replacer?: ((this: any, key: string, value: any) => any) | undefined, space?: string | number | undefined): string; (value: any, replacer?: (string | number)[] | null | undefined, space?: string | number | undefined): string; } >JSON : JSON ->stringify : { (value: Function | Symbol | undefined, replacer?: (string | number)[] | null | undefined, space?: string | number | undefined): undefined; (value: any, replacer?: ((this: any, key: string, value: any) => any) | undefined, space?: string | number | undefined): string; (value: any, replacer?: (string | number)[] | null | undefined, space?: string | number | undefined): string; } +>stringify : { (value: any, replacer?: ((this: any, key: string, value: any) => any) | undefined, space?: string | number | undefined): string; (value: any, replacer?: (string | number)[] | null | undefined, space?: string | number | undefined): string; } >value : null >undefined : undefined >2 : 2 JSON.stringify(value, null, 2); >JSON.stringify(value, null, 2) : string ->JSON.stringify : { (value: Function | Symbol | undefined, replacer?: (string | number)[] | null | undefined, space?: string | number | undefined): undefined; (value: any, replacer?: ((this: any, key: string, value: any) => any) | undefined, space?: string | number | undefined): string; (value: any, replacer?: (string | number)[] | null | undefined, space?: string | number | undefined): string; } +>JSON.stringify : { (value: any, replacer?: ((this: any, key: string, value: any) => any) | undefined, space?: string | number | undefined): string; (value: any, replacer?: (string | number)[] | null | undefined, space?: string | number | undefined): string; } >JSON : JSON ->stringify : { (value: Function | Symbol | undefined, replacer?: (string | number)[] | null | undefined, space?: string | number | undefined): undefined; (value: any, replacer?: ((this: any, key: string, value: any) => any) | undefined, space?: string | number | undefined): string; (value: any, replacer?: (string | number)[] | null | undefined, space?: string | number | undefined): string; } +>stringify : { (value: any, replacer?: ((this: any, key: string, value: any) => any) | undefined, space?: string | number | undefined): string; (value: any, replacer?: (string | number)[] | null | undefined, space?: string | number | undefined): string; } >value : null >null : null >2 : 2 JSON.stringify(value, ["a", 1], 2); >JSON.stringify(value, ["a", 1], 2) : string ->JSON.stringify : { (value: Function | Symbol | undefined, replacer?: (string | number)[] | null | undefined, space?: string | number | undefined): undefined; (value: any, replacer?: ((this: any, key: string, value: any) => any) | undefined, space?: string | number | undefined): string; (value: any, replacer?: (string | number)[] | null | undefined, space?: string | number | undefined): string; } +>JSON.stringify : { (value: any, replacer?: ((this: any, key: string, value: any) => any) | undefined, space?: string | number | undefined): string; (value: any, replacer?: (string | number)[] | null | undefined, space?: string | number | undefined): string; } >JSON : JSON ->stringify : { (value: Function | Symbol | undefined, replacer?: (string | number)[] | null | undefined, space?: string | number | undefined): undefined; (value: any, replacer?: ((this: any, key: string, value: any) => any) | undefined, space?: string | number | undefined): string; (value: any, replacer?: (string | number)[] | null | undefined, space?: string | number | undefined): string; } +>stringify : { (value: any, replacer?: ((this: any, key: string, value: any) => any) | undefined, space?: string | number | undefined): string; (value: any, replacer?: (string | number)[] | null | undefined, space?: string | number | undefined): string; } >value : null >["a", 1] : (string | number)[] >"a" : "a" @@ -34,41 +34,21 @@ JSON.stringify(value, ["a", 1], 2); JSON.stringify(value, (k) => undefined, 2); >JSON.stringify(value, (k) => undefined, 2) : string ->JSON.stringify : { (value: Function | Symbol | undefined, replacer?: (string | number)[] | null | undefined, space?: string | number | undefined): undefined; (value: any, replacer?: ((this: any, key: string, value: any) => any) | undefined, space?: string | number | undefined): string; (value: any, replacer?: (string | number)[] | null | undefined, space?: string | number | undefined): string; } +>JSON.stringify : { (value: any, replacer?: ((this: any, key: string, value: any) => any) | undefined, space?: string | number | undefined): string; (value: any, replacer?: (string | number)[] | null | undefined, space?: string | number | undefined): string; } >JSON : JSON ->stringify : { (value: Function | Symbol | undefined, replacer?: (string | number)[] | null | undefined, space?: string | number | undefined): undefined; (value: any, replacer?: ((this: any, key: string, value: any) => any) | undefined, space?: string | number | undefined): string; (value: any, replacer?: (string | number)[] | null | undefined, space?: string | number | undefined): string; } +>stringify : { (value: any, replacer?: ((this: any, key: string, value: any) => any) | undefined, space?: string | number | undefined): string; (value: any, replacer?: (string | number)[] | null | undefined, space?: string | number | undefined): string; } >value : null >(k) => undefined : (this: any, k: string) => undefined >k : string >undefined : undefined >2 : 2 -JSON.stringify(() => {}, undefined, 2); ->JSON.stringify(() => {}, undefined, 2) : undefined ->JSON.stringify : { (value: Function | Symbol | undefined, replacer?: (string | number)[] | null | undefined, space?: string | number | undefined): undefined; (value: any, replacer?: ((this: any, key: string, value: any) => any) | undefined, space?: string | number | undefined): string; (value: any, replacer?: (string | number)[] | null | undefined, space?: string | number | undefined): string; } ->JSON : JSON ->stringify : { (value: Function | Symbol | undefined, replacer?: (string | number)[] | null | undefined, space?: string | number | undefined): undefined; (value: any, replacer?: ((this: any, key: string, value: any) => any) | undefined, space?: string | number | undefined): string; (value: any, replacer?: (string | number)[] | null | undefined, space?: string | number | undefined): string; } ->() => {} : () => void ->undefined : undefined ->2 : 2 - -JSON.stringify(Symbol('s'), undefined, 2); ->JSON.stringify(Symbol('s'), undefined, 2) : undefined ->JSON.stringify : { (value: Function | Symbol | undefined, replacer?: (string | number)[] | null | undefined, space?: string | number | undefined): undefined; (value: any, replacer?: ((this: any, key: string, value: any) => any) | undefined, space?: string | number | undefined): string; (value: any, replacer?: (string | number)[] | null | undefined, space?: string | number | undefined): string; } ->JSON : JSON ->stringify : { (value: Function | Symbol | undefined, replacer?: (string | number)[] | null | undefined, space?: string | number | undefined): undefined; (value: any, replacer?: ((this: any, key: string, value: any) => any) | undefined, space?: string | number | undefined): string; (value: any, replacer?: (string | number)[] | null | undefined, space?: string | number | undefined): string; } ->Symbol('s') : symbol ->Symbol : SymbolConstructor ->'s' : "s" ->undefined : undefined ->2 : 2 - -JSON.stringify(undefined, undefined, 2); ->JSON.stringify(undefined, undefined, 2) : undefined ->JSON.stringify : { (value: Function | Symbol | undefined, replacer?: (string | number)[] | null | undefined, space?: string | number | undefined): undefined; (value: any, replacer?: ((this: any, key: string, value: any) => any) | undefined, space?: string | number | undefined): string; (value: any, replacer?: (string | number)[] | null | undefined, space?: string | number | undefined): string; } +JSON.stringify(value, undefined, 2); +>JSON.stringify(value, undefined, 2) : string +>JSON.stringify : { (value: any, replacer?: ((this: any, key: string, value: any) => any) | undefined, space?: string | number | undefined): string; (value: any, replacer?: (string | number)[] | null | undefined, space?: string | number | undefined): string; } >JSON : JSON ->stringify : { (value: Function | Symbol | undefined, replacer?: (string | number)[] | null | undefined, space?: string | number | undefined): undefined; (value: any, replacer?: ((this: any, key: string, value: any) => any) | undefined, space?: string | number | undefined): string; (value: any, replacer?: (string | number)[] | null | undefined, space?: string | number | undefined): string; } ->undefined : undefined +>stringify : { (value: any, replacer?: ((this: any, key: string, value: any) => any) | undefined, space?: string | number | undefined): string; (value: any, replacer?: (string | number)[] | null | undefined, space?: string | number | undefined): string; } +>value : null >undefined : undefined >2 : 2 diff --git a/tests/baselines/reference/mappedTypeWithAsClauseAndLateBoundProperty.errors.txt b/tests/baselines/reference/mappedTypeWithAsClauseAndLateBoundProperty.errors.txt index 2e396a60f93eb..4ce90177920e9 100644 --- a/tests/baselines/reference/mappedTypeWithAsClauseAndLateBoundProperty.errors.txt +++ b/tests/baselines/reference/mappedTypeWithAsClauseAndLateBoundProperty.errors.txt @@ -7,5 +7,5 @@ tests/cases/compiler/mappedTypeWithAsClauseAndLateBoundProperty.ts(3,1): error T tgt2 = src2; // Should error ~~~~ !!! error TS2741: Property 'length' is missing in type '{ [x: number]: number; toString: () => string; toLocaleString: () => string; pop: () => number; push: (...items: number[]) => number; concat: { (...items: ConcatArray[]): number[]; (...items: (number | ConcatArray)[]): number[]; }; join: (separator?: string) => string; reverse: () => number[]; shift: () => number; slice: (start?: number, end?: number) => number[]; sort: (compareFn?: (a: number, b: number) => number) => number[]; splice: { (start: number, deleteCount?: number): number[]; (start: number, deleteCount: number, ...items: number[]): number[]; }; unshift: (...items: number[]) => number; indexOf: (searchElement: number, fromIndex?: number) => number; lastIndexOf: (searchElement: number, fromIndex?: number) => number; every: { (predicate: (value: number, index: number, array: number[]) => value is S, thisArg?: any): this is S[]; (predicate: (value: number, index: number, array: number[]) => unknown, thisArg?: any): boolean; }; some: (predicate: (value: number, index: number, array: number[]) => unknown, thisArg?: any) => boolean; forEach: (callbackfn: (value: number, index: number, array: number[]) => void, thisArg?: any) => void; map: (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any) => U[]; filter: { (predicate: (value: number, index: number, array: number[]) => value is S, thisArg?: any): S[]; (predicate: (value: number, index: number, array: number[]) => unknown, thisArg?: any): number[]; }; reduce: { (callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: number[]) => number): number; (callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: number[]) => number, initialValue: number): number; (callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: number[]) => U, initialValue: U): U; }; reduceRight: { (callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: number[]) => number): number; (callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: number[]) => number, initialValue: number): number; (callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: number[]) => U, initialValue: U): U; }; find: { (predicate: (value: number, index: number, obj: number[]) => value is S, thisArg?: any): S; (predicate: (value: number, index: number, obj: number[]) => unknown, thisArg?: any): number; }; findIndex: (predicate: (value: number, index: number, obj: number[]) => unknown, thisArg?: any) => number; fill: (value: number, start?: number, end?: number) => number[]; copyWithin: (target: number, start: number, end?: number) => number[]; entries: () => IterableIterator<[number, number]>; keys: () => IterableIterator; values: () => IterableIterator; includes: (searchElement: number, fromIndex?: number) => boolean; flatMap: (callback: (this: This, value: number, index: number, array: number[]) => U | readonly U[], thisArg?: This) => U[]; flat: (this: A, depth?: D) => FlatArray[]; [iterator]: () => IterableIterator; [unscopables]: () => { copyWithin: boolean; entries: boolean; fill: boolean; find: boolean; findIndex: boolean; keys: boolean; values: boolean; }; }' but required in type 'number[]'. -!!! related TS2728 /.ts/lib.es5.d.ts:1311:5: 'length' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:1304:5: 'length' is declared here. \ No newline at end of file diff --git a/tests/baselines/reference/parserharness.symbols b/tests/baselines/reference/parserharness.symbols index f49c8022e2948..62604cadf5a19 100644 --- a/tests/baselines/reference/parserharness.symbols +++ b/tests/baselines/reference/parserharness.symbols @@ -5576,9 +5576,9 @@ module Harness { >getHostSettings : Symbol(TypeScriptLS.getHostSettings, Decl(parserharness.ts, 1836, 9)) return JSON.stringify({ usePullLanguageService: usePull }); ->JSON.stringify : Symbol(JSON.stringify, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>JSON.stringify : Symbol(JSON.stringify, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >JSON : Symbol(JSON, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) ->stringify : Symbol(JSON.stringify, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>stringify : Symbol(JSON.stringify, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >usePullLanguageService : Symbol(usePullLanguageService, Decl(parserharness.ts, 1839, 35)) >usePull : Symbol(usePull, Decl(parserharness.ts, 58, 14)) } diff --git a/tests/baselines/reference/parserharness.types b/tests/baselines/reference/parserharness.types index adf2bf2a75664..498e9bf7ea7ce 100644 --- a/tests/baselines/reference/parserharness.types +++ b/tests/baselines/reference/parserharness.types @@ -7549,9 +7549,9 @@ module Harness { return JSON.stringify({ usePullLanguageService: usePull }); >JSON.stringify({ usePullLanguageService: usePull }) : string ->JSON.stringify : { (value: Function | Symbol, replacer?: (string | number)[], space?: string | number): undefined; (value: any, replacer?: (this: any, key: string, value: any) => any, space?: string | number): string; (value: any, replacer?: (string | number)[], space?: string | number): string; } +>JSON.stringify : { (value: any, replacer?: (this: any, key: string, value: any) => any, space?: string | number): string; (value: any, replacer?: (string | number)[], space?: string | number): string; } >JSON : JSON ->stringify : { (value: Function | Symbol, replacer?: (string | number)[], space?: string | number): undefined; (value: any, replacer?: (this: any, key: string, value: any) => any, space?: string | number): string; (value: any, replacer?: (string | number)[], space?: string | number): string; } +>stringify : { (value: any, replacer?: (this: any, key: string, value: any) => any, space?: string | number): string; (value: any, replacer?: (string | number)[], space?: string | number): string; } >{ usePullLanguageService: usePull } : { usePullLanguageService: boolean; } >usePullLanguageService : boolean >usePull : boolean diff --git a/tests/baselines/reference/promisePermutations.errors.txt b/tests/baselines/reference/promisePermutations.errors.txt index da49eaf0222aa..7bc65540d1aa4 100644 --- a/tests/baselines/reference/promisePermutations.errors.txt +++ b/tests/baselines/reference/promisePermutations.errors.txt @@ -447,7 +447,7 @@ tests/cases/compiler/promisePermutations.ts(160,21): error TS2769: No overload m !!! error TS2769: The last overload gave the following error. !!! error TS2769: Argument of type '(x: any) => IPromise' is not assignable to parameter of type '(error: any) => Promise'. !!! error TS2769: Property 'catch' is missing in type 'IPromise' but required in type 'Promise'. -!!! related TS2728 /.ts/lib.es5.d.ts:1547:5: 'catch' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:1540:5: 'catch' is declared here. !!! related TS2771 tests/cases/compiler/promisePermutations.ts:5:5: The last overload is declared here. var s10g = s10.then(testFunctionP, nIPromise, sIPromise).then(sPromise, sIPromise, sIPromise); // ok diff --git a/tests/baselines/reference/promisePermutations2.errors.txt b/tests/baselines/reference/promisePermutations2.errors.txt index 871c3b5774435..000994163afbb 100644 --- a/tests/baselines/reference/promisePermutations2.errors.txt +++ b/tests/baselines/reference/promisePermutations2.errors.txt @@ -351,7 +351,7 @@ tests/cases/compiler/promisePermutations2.ts(159,21): error TS2345: Argument of ~~~~~~~~~ !!! error TS2345: Argument of type '(x: any) => IPromise' is not assignable to parameter of type '(error: any) => Promise'. !!! error TS2345: Property 'catch' is missing in type 'IPromise' but required in type 'Promise'. -!!! related TS2728 /.ts/lib.es5.d.ts:1547:5: 'catch' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:1540:5: 'catch' is declared here. var s10g = s10.then(testFunctionP, nIPromise, sIPromise).then(sPromise, sIPromise, sIPromise); // ok var r11: IPromise; diff --git a/tests/baselines/reference/promisePermutations3.errors.txt b/tests/baselines/reference/promisePermutations3.errors.txt index f17dbf7e58983..e0c7a897ed481 100644 --- a/tests/baselines/reference/promisePermutations3.errors.txt +++ b/tests/baselines/reference/promisePermutations3.errors.txt @@ -398,7 +398,7 @@ tests/cases/compiler/promisePermutations3.ts(165,21): error TS2345: Argument of !!! error TS2769: The last overload gave the following error. !!! error TS2769: Argument of type '(x: any) => IPromise' is not assignable to parameter of type '(error: any) => Promise'. !!! error TS2769: Property 'catch' is missing in type 'IPromise' but required in type 'Promise'. -!!! related TS2728 /.ts/lib.es5.d.ts:1547:5: 'catch' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:1540:5: 'catch' is declared here. !!! related TS2771 tests/cases/compiler/promisePermutations3.ts:7:5: The last overload is declared here. var s10g = s10.then(testFunctionP, nIPromise, sIPromise).then(sPromise, sIPromise, sIPromise); // ok @@ -445,5 +445,5 @@ tests/cases/compiler/promisePermutations3.ts(165,21): error TS2345: Argument of ~~~~~~~~~~~~~~~ !!! error TS2345: Argument of type '{ (x: T): IPromise; (x: T, y: T): Promise; }' is not assignable to parameter of type '(value: (x: any) => any) => Promise'. !!! error TS2345: Property 'catch' is missing in type 'IPromise' but required in type 'Promise'. -!!! related TS2728 /.ts/lib.es5.d.ts:1547:5: 'catch' is declared here. +!!! related TS2728 /.ts/lib.es5.d.ts:1540:5: 'catch' is declared here. var s12c = s12.then(testFunction12P, testFunction12, testFunction12); // ok \ No newline at end of file diff --git a/tests/baselines/reference/redefineArray.errors.txt b/tests/baselines/reference/redefineArray.errors.txt index 2693385983841..468b3e9e823c2 100644 --- a/tests/baselines/reference/redefineArray.errors.txt +++ b/tests/baselines/reference/redefineArray.errors.txt @@ -5,4 +5,4 @@ tests/cases/compiler/redefineArray.ts(1,1): error TS2741: Property 'isArray' is Array = function (n:number, s:string) {return n;}; ~~~~~ !!! error TS2741: Property 'isArray' is missing in type '(n: number, s: string) => number' but required in type 'ArrayConstructor'. -!!! related TS2728 /.ts/lib.es5.d.ts:1498:5: 'isArray' is declared here. \ No newline at end of file +!!! related TS2728 /.ts/lib.es5.d.ts:1491:5: 'isArray' is declared here. \ No newline at end of file diff --git a/tests/baselines/reference/staticAnonymousTypeNotReferencingTypeParameter.symbols b/tests/baselines/reference/staticAnonymousTypeNotReferencingTypeParameter.symbols index 7c7294228241c..5bcfebca97ce8 100644 --- a/tests/baselines/reference/staticAnonymousTypeNotReferencingTypeParameter.symbols +++ b/tests/baselines/reference/staticAnonymousTypeNotReferencingTypeParameter.symbols @@ -562,9 +562,9 @@ class ListWrapper { >ListWrapper : Symbol(ListWrapper, Decl(staticAnonymousTypeNotReferencingTypeParameter.ts, 38, 1)) >l : Symbol(l, Decl(staticAnonymousTypeNotReferencingTypeParameter.ts, 113, 43)) >T : Symbol(T, Decl(staticAnonymousTypeNotReferencingTypeParameter.ts, 113, 16)) ->JSON.stringify : Symbol(JSON.stringify, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>JSON.stringify : Symbol(JSON.stringify, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >JSON : Symbol(JSON, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) ->stringify : Symbol(JSON.stringify, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>stringify : Symbol(JSON.stringify, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >l : Symbol(l, Decl(staticAnonymousTypeNotReferencingTypeParameter.ts, 113, 43)) static maximum(dit: typeof ListWrapper, list: T[], predicate: (t: T) => number): T { diff --git a/tests/baselines/reference/staticAnonymousTypeNotReferencingTypeParameter.types b/tests/baselines/reference/staticAnonymousTypeNotReferencingTypeParameter.types index 82c9b17f50302..cd907c26ec802 100644 --- a/tests/baselines/reference/staticAnonymousTypeNotReferencingTypeParameter.types +++ b/tests/baselines/reference/staticAnonymousTypeNotReferencingTypeParameter.types @@ -594,9 +594,9 @@ class ListWrapper { >ListWrapper : typeof ListWrapper >l : T[] >JSON.stringify(l) : string ->JSON.stringify : { (value: Function | Symbol, replacer?: (string | number)[], space?: string | number): undefined; (value: any, replacer?: (this: any, key: string, value: any) => any, space?: string | number): string; (value: any, replacer?: (string | number)[], space?: string | number): string; } +>JSON.stringify : { (value: any, replacer?: (this: any, key: string, value: any) => any, space?: string | number): string; (value: any, replacer?: (string | number)[], space?: string | number): string; } >JSON : JSON ->stringify : { (value: Function | Symbol, replacer?: (string | number)[], space?: string | number): undefined; (value: any, replacer?: (this: any, key: string, value: any) => any, space?: string | number): string; (value: any, replacer?: (string | number)[], space?: string | number): string; } +>stringify : { (value: any, replacer?: (this: any, key: string, value: any) => any, space?: string | number): string; (value: any, replacer?: (string | number)[], space?: string | number): string; } >l : T[] static maximum(dit: typeof ListWrapper, list: T[], predicate: (t: T) => number): T { diff --git a/tests/cases/compiler/json.stringify.ts b/tests/cases/compiler/json.stringify.ts index c6e82abcaf0fc..58400f859df60 100644 --- a/tests/cases/compiler/json.stringify.ts +++ b/tests/cases/compiler/json.stringify.ts @@ -1,11 +1,8 @@ // @strictNullChecks: true -// @lib: es2015 var value = null; JSON.stringify(value, undefined, 2); JSON.stringify(value, null, 2); JSON.stringify(value, ["a", 1], 2); JSON.stringify(value, (k) => undefined, 2); -JSON.stringify(() => {}, undefined, 2); -JSON.stringify(Symbol('s'), undefined, 2); -JSON.stringify(undefined, undefined, 2); \ No newline at end of file +JSON.stringify(value, undefined, 2); \ No newline at end of file From acc82738cf6ec29065169e26ed6d03b520ec4ebc Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Thu, 19 Jan 2023 08:49:10 -0800 Subject: [PATCH 2/3] Update api baselines --- .../reference/api/tsserverlibrary.d.ts | 98 +++++-------------- tests/baselines/reference/api/typescript.d.ts | 84 ++++------------ 2 files changed, 40 insertions(+), 142 deletions(-) diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index 35d7f3eab8a10..695ea34540129 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -3729,7 +3729,7 @@ declare namespace ts { private enableRequestedPluginsForProjectAsync; configurePlugin(args: protocol.ConfigurePluginRequestArguments): void; } - function formatMessage(msg: T, logger: Logger, byteLength: (s: string, encoding: BufferEncoding) => number, newLine: string): string; + function formatMessage(msg: T, logger: Logger, byteLength: (s: string, encoding: string) => number, newLine: string): string; interface ServerCancellationToken extends HostCancellationToken { setRequest(requestId: number): void; resetRequest(requestId: number): void; @@ -3751,14 +3751,8 @@ declare namespace ts { useSingleInferredProject: boolean; useInferredProjectPerProjectRoot: boolean; typingsInstaller: ITypingsInstaller; - byteLength: (buf: string, encoding?: BufferEncoding) => number; - hrtime: (start?: [ - number, - number - ]) => [ - number, - number - ]; + byteLength: (buf: string, encoding?: string) => number; + hrtime: (start?: number[]) => number[]; logger: Logger; /** * If falsy, all events are suppressed. @@ -3787,7 +3781,7 @@ declare namespace ts { protected host: ServerHost; private readonly cancellationToken; protected readonly typingsInstaller: ITypingsInstaller; - protected byteLength: (buf: string, encoding?: BufferEncoding) => number; + protected byteLength: (buf: string, encoding?: string) => number; private hrtime; protected logger: Logger; protected canUseEvents: boolean; @@ -7828,10 +7822,10 @@ declare namespace ts { updateJSDocReadonlyTag(node: JSDocReadonlyTag, tagName: Identifier | undefined, comment: string | NodeArray | undefined): JSDocReadonlyTag; createJSDocUnknownTag(tagName: Identifier, comment?: string | NodeArray): JSDocUnknownTag; 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; - createJSDocOverrideTag(tagName: Identifier | undefined, comment?: string | NodeArray): JSDocOverrideTag; - updateJSDocOverrideTag(node: JSDocOverrideTag, tagName: Identifier | undefined, comment?: string | NodeArray): JSDocOverrideTag; + createJSDocDeprecatedTag(tagName: Identifier, comment?: string | NodeArray): JSDocDeprecatedTag; + updateJSDocDeprecatedTag(node: JSDocDeprecatedTag, tagName: Identifier, comment?: string | NodeArray): JSDocDeprecatedTag; + createJSDocOverrideTag(tagName: Identifier, comment?: string | NodeArray): JSDocOverrideTag; + updateJSDocOverrideTag(node: JSDocOverrideTag, tagName: Identifier, comment?: string | NodeArray): JSDocOverrideTag; createJSDocThrowsTag(tagName: Identifier, typeExpression: JSDocTypeExpression | undefined, comment?: string | NodeArray): JSDocThrowsTag; updateJSDocThrowsTag(node: JSDocThrowsTag, tagName: Identifier | undefined, typeExpression: JSDocTypeExpression | undefined, comment?: string | NodeArray | undefined): JSDocThrowsTag; createJSDocSatisfiesTag(tagName: Identifier | undefined, typeExpression: JSDocTypeExpression, comment?: string | NodeArray): JSDocSatisfiesTag; @@ -8198,39 +8192,16 @@ declare namespace ts { /** * A function that accepts and possibly transforms a node. */ - type Visitor = (node: TIn) => VisitResult; - /** - * A function that walks a node using the given visitor, lifting node arrays into single nodes, - * returning an node which satisfies the test. - * - * - If the input node is undefined, then the output is undefined. - * - If the visitor returns undefined, then the output is undefined. - * - If the output node is not undefined, then it will satisfy the test function. - * - In order to obtain a return type that is more specific than `Node`, a test - * function _must_ be provided, and that function must be a type predicate. - * - * For the canonical implementation of this type, @see {visitNode}. - */ + type Visitor = (node: Node) => VisitResult; interface NodeVisitor { - (node: TIn, visitor: Visitor, TVisited>, test: (node: Node) => node is TOut, lift?: (node: readonly Node[]) => Node): TOut | (TIn & undefined) | (TVisited & undefined); - (node: TIn, visitor: Visitor, TVisited>, test?: (node: Node) => boolean, lift?: (node: readonly Node[]) => Node): Node | (TIn & undefined) | (TVisited & undefined); + (nodes: T, visitor: Visitor | undefined, test?: (node: Node) => boolean, lift?: (node: readonly Node[]) => T): T; + (nodes: T | undefined, visitor: Visitor | undefined, test?: (node: Node) => boolean, lift?: (node: readonly Node[]) => T): T | undefined; } - /** - * A function that walks a node array using the given visitor, returning an array whose contents satisfy the test. - * - * - If the input node array is undefined, the output is undefined. - * - If the visitor can return undefined, the node it visits in the array will be reused. - * - If the output node array is not undefined, then its contents will satisfy the test. - * - In order to obtain a return type that is more specific than `NodeArray`, a test - * function _must_ be provided, and that function must be a type predicate. - * - * For the canonical implementation of this type, @see {visitNodes}. - */ interface NodesVisitor { - | undefined, TOut extends Node>(nodes: TInArray, visitor: Visitor, test: (node: Node) => node is TOut, start?: number, count?: number): NodeArray | (TInArray & undefined); - | undefined>(nodes: TInArray, visitor: Visitor, test?: (node: Node) => boolean, start?: number, count?: number): NodeArray | (TInArray & undefined); + (nodes: NodeArray, visitor: Visitor | undefined, test?: (node: Node) => boolean, start?: number, count?: number): NodeArray; + (nodes: NodeArray | undefined, visitor: Visitor | undefined, test?: (node: Node) => boolean, start?: number, count?: number): NodeArray | undefined; } - type VisitResult = T | readonly Node[]; + type VisitResult = T | readonly T[] | undefined; interface Printer { /** * Print a node and its subtree as-is, without any emit transformations. @@ -8444,7 +8415,6 @@ declare namespace ts { } type FileWatcherCallback = (fileName: string, eventKind: FileWatcherEventKind, modifiedTime?: Date) => void; type DirectoryWatcherCallback = (fileName: string) => void; - type BufferEncoding = "ascii" | "utf8" | "utf-8" | "utf16le" | "ucs2" | "ucs-2" | "base64" | "latin1" | "binary" | "hex"; interface System { args: string[]; newLine: string; @@ -8503,8 +8473,8 @@ declare namespace ts { function forEachLeadingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean, state: T) => U, state: T): U | undefined; function forEachTrailingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean) => U): U | undefined; function forEachTrailingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean, state: T) => U, state: T): U | undefined; - function reduceEachLeadingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean, state: T) => U, state: T, initial: U): U | undefined; - function reduceEachTrailingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean, state: T) => U, state: T, initial: U): U | undefined; + function reduceEachLeadingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean, state: T, memo: U) => U, state: T, initial: U): U | undefined; + function reduceEachTrailingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean, state: T, memo: U) => U, state: T, initial: U): U | undefined; function getLeadingCommentRanges(text: string, pos: number): CommentRange[] | undefined; function getTrailingCommentRanges(text: string, pos: number): CommentRange[] | undefined; /** Optionally, get the shebang */ @@ -8583,7 +8553,7 @@ declare namespace ts { function getTypeParameterOwner(d: Declaration): Declaration | undefined; function isParameterPropertyDeclaration(node: Node, parent: Node): node is ParameterPropertyDeclaration; function isEmptyBindingPattern(node: BindingName): node is BindingPattern; - function isEmptyBindingElement(node: BindingElement | ArrayBindingElement): boolean; + function isEmptyBindingElement(node: BindingElement): boolean; function walkUpBindingElementsAndPatterns(binding: BindingElement): VariableDeclaration | ParameterDeclaration; function getCombinedModifierFlags(node: Declaration): ModifierFlags; function getCombinedNodeFlags(node: Node): NodeFlags; @@ -8600,7 +8570,7 @@ declare namespace ts { function getOriginalNode(node: Node): Node; function getOriginalNode(node: Node, nodeTest: (node: Node) => node is T): T; function getOriginalNode(node: Node | undefined): Node | undefined; - function getOriginalNode(node: Node | undefined, nodeTest: (node: Node) => node is T): T | undefined; + function getOriginalNode(node: Node | undefined, nodeTest: (node: Node | undefined) => node is T): T | undefined; /** * Iterates through the parent chain of a node and performs the callback on each parent until the callback * returns a truthy value, then returns that value. @@ -9318,65 +9288,41 @@ declare namespace ts { /** * Visits a Node using the supplied visitor, possibly returning a new Node in its place. * - * - If the input node is undefined, then the output is undefined. - * - If the visitor returns undefined, then the output is undefined. - * - If the output node is not undefined, then it will satisfy the test function. - * - In order to obtain a return type that is more specific than `Node`, a test - * function _must_ be provided, and that function must be a type predicate. - * * @param node The Node to visit. * @param visitor The callback used to visit the Node. * @param test A callback to execute to verify the Node is valid. * @param lift An optional callback to execute to lift a NodeArray into a valid Node. */ - function visitNode(node: TIn, visitor: Visitor, TVisited>, test: (node: Node) => node is TOut, lift?: (node: readonly Node[]) => Node): TOut | (TIn & undefined) | (TVisited & undefined); + function visitNode(node: T, visitor: Visitor | undefined, test?: (node: Node) => boolean, lift?: (node: readonly Node[]) => T): T; /** * Visits a Node using the supplied visitor, possibly returning a new Node in its place. * - * - If the input node is undefined, then the output is undefined. - * - If the visitor returns undefined, then the output is undefined. - * - If the output node is not undefined, then it will satisfy the test function. - * - In order to obtain a return type that is more specific than `Node`, a test - * function _must_ be provided, and that function must be a type predicate. - * * @param node The Node to visit. * @param visitor The callback used to visit the Node. * @param test A callback to execute to verify the Node is valid. * @param lift An optional callback to execute to lift a NodeArray into a valid Node. */ - function visitNode(node: TIn, visitor: Visitor, TVisited>, test?: (node: Node) => boolean, lift?: (node: readonly Node[]) => Node): Node | (TIn & undefined) | (TVisited & undefined); + function visitNode(node: T | undefined, visitor: Visitor | undefined, test?: (node: Node) => boolean, lift?: (node: readonly Node[]) => T): T | undefined; /** * Visits a NodeArray using the supplied visitor, possibly returning a new NodeArray in its place. * - * - If the input node array is undefined, the output is undefined. - * - If the visitor can return undefined, the node it visits in the array will be reused. - * - If the output node array is not undefined, then its contents will satisfy the test. - * - In order to obtain a return type that is more specific than `NodeArray`, a test - * function _must_ be provided, and that function must be a type predicate. - * * @param nodes The NodeArray to visit. * @param visitor The callback used to visit a Node. * @param test A node test to execute for each node. * @param start An optional value indicating the starting offset at which to start visiting. * @param count An optional value indicating the maximum number of nodes to visit. */ - function visitNodes | undefined, TOut extends Node>(nodes: TInArray, visitor: Visitor, test: (node: Node) => node is TOut, start?: number, count?: number): NodeArray | (TInArray & undefined); + function visitNodes(nodes: NodeArray, visitor: Visitor | undefined, test?: (node: Node) => boolean, start?: number, count?: number): NodeArray; /** * Visits a NodeArray using the supplied visitor, possibly returning a new NodeArray in its place. * - * - If the input node array is undefined, the output is undefined. - * - If the visitor can return undefined, the node it visits in the array will be reused. - * - If the output node array is not undefined, then its contents will satisfy the test. - * - In order to obtain a return type that is more specific than `NodeArray`, a test - * function _must_ be provided, and that function must be a type predicate. - * * @param nodes The NodeArray to visit. * @param visitor The callback used to visit a Node. * @param test A node test to execute for each node. * @param start An optional value indicating the starting offset at which to start visiting. * @param count An optional value indicating the maximum number of nodes to visit. */ - function visitNodes | undefined>(nodes: TInArray, visitor: Visitor, test?: (node: Node) => boolean, start?: number, count?: number): NodeArray | (TInArray & undefined); + function visitNodes(nodes: NodeArray | undefined, visitor: Visitor | undefined, test?: (node: Node) => boolean, start?: number, count?: number): NodeArray | undefined; /** * Starts a new lexical environment and visits a statement list, ending the lexical environment * and merging hoisted declarations upon completion. diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index 6c4dd8cf96b43..32b2585c29f7e 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -3887,10 +3887,10 @@ declare namespace ts { updateJSDocReadonlyTag(node: JSDocReadonlyTag, tagName: Identifier | undefined, comment: string | NodeArray | undefined): JSDocReadonlyTag; createJSDocUnknownTag(tagName: Identifier, comment?: string | NodeArray): JSDocUnknownTag; 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; - createJSDocOverrideTag(tagName: Identifier | undefined, comment?: string | NodeArray): JSDocOverrideTag; - updateJSDocOverrideTag(node: JSDocOverrideTag, tagName: Identifier | undefined, comment?: string | NodeArray): JSDocOverrideTag; + createJSDocDeprecatedTag(tagName: Identifier, comment?: string | NodeArray): JSDocDeprecatedTag; + updateJSDocDeprecatedTag(node: JSDocDeprecatedTag, tagName: Identifier, comment?: string | NodeArray): JSDocDeprecatedTag; + createJSDocOverrideTag(tagName: Identifier, comment?: string | NodeArray): JSDocOverrideTag; + updateJSDocOverrideTag(node: JSDocOverrideTag, tagName: Identifier, comment?: string | NodeArray): JSDocOverrideTag; createJSDocThrowsTag(tagName: Identifier, typeExpression: JSDocTypeExpression | undefined, comment?: string | NodeArray): JSDocThrowsTag; updateJSDocThrowsTag(node: JSDocThrowsTag, tagName: Identifier | undefined, typeExpression: JSDocTypeExpression | undefined, comment?: string | NodeArray | undefined): JSDocThrowsTag; createJSDocSatisfiesTag(tagName: Identifier | undefined, typeExpression: JSDocTypeExpression, comment?: string | NodeArray): JSDocSatisfiesTag; @@ -4257,39 +4257,16 @@ declare namespace ts { /** * A function that accepts and possibly transforms a node. */ - type Visitor = (node: TIn) => VisitResult; - /** - * A function that walks a node using the given visitor, lifting node arrays into single nodes, - * returning an node which satisfies the test. - * - * - If the input node is undefined, then the output is undefined. - * - If the visitor returns undefined, then the output is undefined. - * - If the output node is not undefined, then it will satisfy the test function. - * - In order to obtain a return type that is more specific than `Node`, a test - * function _must_ be provided, and that function must be a type predicate. - * - * For the canonical implementation of this type, @see {visitNode}. - */ + type Visitor = (node: Node) => VisitResult; interface NodeVisitor { - (node: TIn, visitor: Visitor, TVisited>, test: (node: Node) => node is TOut, lift?: (node: readonly Node[]) => Node): TOut | (TIn & undefined) | (TVisited & undefined); - (node: TIn, visitor: Visitor, TVisited>, test?: (node: Node) => boolean, lift?: (node: readonly Node[]) => Node): Node | (TIn & undefined) | (TVisited & undefined); + (nodes: T, visitor: Visitor | undefined, test?: (node: Node) => boolean, lift?: (node: readonly Node[]) => T): T; + (nodes: T | undefined, visitor: Visitor | undefined, test?: (node: Node) => boolean, lift?: (node: readonly Node[]) => T): T | undefined; } - /** - * A function that walks a node array using the given visitor, returning an array whose contents satisfy the test. - * - * - If the input node array is undefined, the output is undefined. - * - If the visitor can return undefined, the node it visits in the array will be reused. - * - If the output node array is not undefined, then its contents will satisfy the test. - * - In order to obtain a return type that is more specific than `NodeArray`, a test - * function _must_ be provided, and that function must be a type predicate. - * - * For the canonical implementation of this type, @see {visitNodes}. - */ interface NodesVisitor { - | undefined, TOut extends Node>(nodes: TInArray, visitor: Visitor, test: (node: Node) => node is TOut, start?: number, count?: number): NodeArray | (TInArray & undefined); - | undefined>(nodes: TInArray, visitor: Visitor, test?: (node: Node) => boolean, start?: number, count?: number): NodeArray | (TInArray & undefined); + (nodes: NodeArray, visitor: Visitor | undefined, test?: (node: Node) => boolean, start?: number, count?: number): NodeArray; + (nodes: NodeArray | undefined, visitor: Visitor | undefined, test?: (node: Node) => boolean, start?: number, count?: number): NodeArray | undefined; } - type VisitResult = T | readonly Node[]; + type VisitResult = T | readonly T[] | undefined; interface Printer { /** * Print a node and its subtree as-is, without any emit transformations. @@ -4503,7 +4480,6 @@ declare namespace ts { } type FileWatcherCallback = (fileName: string, eventKind: FileWatcherEventKind, modifiedTime?: Date) => void; type DirectoryWatcherCallback = (fileName: string) => void; - type BufferEncoding = "ascii" | "utf8" | "utf-8" | "utf16le" | "ucs2" | "ucs-2" | "base64" | "latin1" | "binary" | "hex"; interface System { args: string[]; newLine: string; @@ -4562,8 +4538,8 @@ declare namespace ts { function forEachLeadingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean, state: T) => U, state: T): U | undefined; function forEachTrailingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean) => U): U | undefined; function forEachTrailingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean, state: T) => U, state: T): U | undefined; - function reduceEachLeadingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean, state: T) => U, state: T, initial: U): U | undefined; - function reduceEachTrailingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean, state: T) => U, state: T, initial: U): U | undefined; + function reduceEachLeadingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean, state: T, memo: U) => U, state: T, initial: U): U | undefined; + function reduceEachTrailingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean, state: T, memo: U) => U, state: T, initial: U): U | undefined; function getLeadingCommentRanges(text: string, pos: number): CommentRange[] | undefined; function getTrailingCommentRanges(text: string, pos: number): CommentRange[] | undefined; /** Optionally, get the shebang */ @@ -4642,7 +4618,7 @@ declare namespace ts { function getTypeParameterOwner(d: Declaration): Declaration | undefined; function isParameterPropertyDeclaration(node: Node, parent: Node): node is ParameterPropertyDeclaration; function isEmptyBindingPattern(node: BindingName): node is BindingPattern; - function isEmptyBindingElement(node: BindingElement | ArrayBindingElement): boolean; + function isEmptyBindingElement(node: BindingElement): boolean; function walkUpBindingElementsAndPatterns(binding: BindingElement): VariableDeclaration | ParameterDeclaration; function getCombinedModifierFlags(node: Declaration): ModifierFlags; function getCombinedNodeFlags(node: Node): NodeFlags; @@ -4659,7 +4635,7 @@ declare namespace ts { function getOriginalNode(node: Node): Node; function getOriginalNode(node: Node, nodeTest: (node: Node) => node is T): T; function getOriginalNode(node: Node | undefined): Node | undefined; - function getOriginalNode(node: Node | undefined, nodeTest: (node: Node) => node is T): T | undefined; + function getOriginalNode(node: Node | undefined, nodeTest: (node: Node | undefined) => node is T): T | undefined; /** * Iterates through the parent chain of a node and performs the callback on each parent until the callback * returns a truthy value, then returns that value. @@ -5377,65 +5353,41 @@ declare namespace ts { /** * Visits a Node using the supplied visitor, possibly returning a new Node in its place. * - * - If the input node is undefined, then the output is undefined. - * - If the visitor returns undefined, then the output is undefined. - * - If the output node is not undefined, then it will satisfy the test function. - * - In order to obtain a return type that is more specific than `Node`, a test - * function _must_ be provided, and that function must be a type predicate. - * * @param node The Node to visit. * @param visitor The callback used to visit the Node. * @param test A callback to execute to verify the Node is valid. * @param lift An optional callback to execute to lift a NodeArray into a valid Node. */ - function visitNode(node: TIn, visitor: Visitor, TVisited>, test: (node: Node) => node is TOut, lift?: (node: readonly Node[]) => Node): TOut | (TIn & undefined) | (TVisited & undefined); + function visitNode(node: T, visitor: Visitor | undefined, test?: (node: Node) => boolean, lift?: (node: readonly Node[]) => T): T; /** * Visits a Node using the supplied visitor, possibly returning a new Node in its place. * - * - If the input node is undefined, then the output is undefined. - * - If the visitor returns undefined, then the output is undefined. - * - If the output node is not undefined, then it will satisfy the test function. - * - In order to obtain a return type that is more specific than `Node`, a test - * function _must_ be provided, and that function must be a type predicate. - * * @param node The Node to visit. * @param visitor The callback used to visit the Node. * @param test A callback to execute to verify the Node is valid. * @param lift An optional callback to execute to lift a NodeArray into a valid Node. */ - function visitNode(node: TIn, visitor: Visitor, TVisited>, test?: (node: Node) => boolean, lift?: (node: readonly Node[]) => Node): Node | (TIn & undefined) | (TVisited & undefined); + function visitNode(node: T | undefined, visitor: Visitor | undefined, test?: (node: Node) => boolean, lift?: (node: readonly Node[]) => T): T | undefined; /** * Visits a NodeArray using the supplied visitor, possibly returning a new NodeArray in its place. * - * - If the input node array is undefined, the output is undefined. - * - If the visitor can return undefined, the node it visits in the array will be reused. - * - If the output node array is not undefined, then its contents will satisfy the test. - * - In order to obtain a return type that is more specific than `NodeArray`, a test - * function _must_ be provided, and that function must be a type predicate. - * * @param nodes The NodeArray to visit. * @param visitor The callback used to visit a Node. * @param test A node test to execute for each node. * @param start An optional value indicating the starting offset at which to start visiting. * @param count An optional value indicating the maximum number of nodes to visit. */ - function visitNodes | undefined, TOut extends Node>(nodes: TInArray, visitor: Visitor, test: (node: Node) => node is TOut, start?: number, count?: number): NodeArray | (TInArray & undefined); + function visitNodes(nodes: NodeArray, visitor: Visitor | undefined, test?: (node: Node) => boolean, start?: number, count?: number): NodeArray; /** * Visits a NodeArray using the supplied visitor, possibly returning a new NodeArray in its place. * - * - If the input node array is undefined, the output is undefined. - * - If the visitor can return undefined, the node it visits in the array will be reused. - * - If the output node array is not undefined, then its contents will satisfy the test. - * - In order to obtain a return type that is more specific than `NodeArray`, a test - * function _must_ be provided, and that function must be a type predicate. - * * @param nodes The NodeArray to visit. * @param visitor The callback used to visit a Node. * @param test A node test to execute for each node. * @param start An optional value indicating the starting offset at which to start visiting. * @param count An optional value indicating the maximum number of nodes to visit. */ - function visitNodes | undefined>(nodes: TInArray, visitor: Visitor, test?: (node: Node) => boolean, start?: number, count?: number): NodeArray | (TInArray & undefined); + function visitNodes(nodes: NodeArray | undefined, visitor: Visitor | undefined, test?: (node: Node) => boolean, start?: number, count?: number): NodeArray | undefined; /** * Starts a new lexical environment and visits a statement list, ending the lexical environment * and merging hoisted declarations upon completion. From abd52bd67380565f8f15b59bab8d2db37f05190c Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Thu, 19 Jan 2023 09:08:50 -0800 Subject: [PATCH 3/3] Accept API baselines again, with bundle=true --- .../reference/api/tsserverlibrary.d.ts | 98 ++++++++++++++----- tests/baselines/reference/api/typescript.d.ts | 84 ++++++++++++---- 2 files changed, 142 insertions(+), 40 deletions(-) diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index 695ea34540129..35d7f3eab8a10 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -3729,7 +3729,7 @@ declare namespace ts { private enableRequestedPluginsForProjectAsync; configurePlugin(args: protocol.ConfigurePluginRequestArguments): void; } - function formatMessage(msg: T, logger: Logger, byteLength: (s: string, encoding: string) => number, newLine: string): string; + function formatMessage(msg: T, logger: Logger, byteLength: (s: string, encoding: BufferEncoding) => number, newLine: string): string; interface ServerCancellationToken extends HostCancellationToken { setRequest(requestId: number): void; resetRequest(requestId: number): void; @@ -3751,8 +3751,14 @@ declare namespace ts { useSingleInferredProject: boolean; useInferredProjectPerProjectRoot: boolean; typingsInstaller: ITypingsInstaller; - byteLength: (buf: string, encoding?: string) => number; - hrtime: (start?: number[]) => number[]; + byteLength: (buf: string, encoding?: BufferEncoding) => number; + hrtime: (start?: [ + number, + number + ]) => [ + number, + number + ]; logger: Logger; /** * If falsy, all events are suppressed. @@ -3781,7 +3787,7 @@ declare namespace ts { protected host: ServerHost; private readonly cancellationToken; protected readonly typingsInstaller: ITypingsInstaller; - protected byteLength: (buf: string, encoding?: string) => number; + protected byteLength: (buf: string, encoding?: BufferEncoding) => number; private hrtime; protected logger: Logger; protected canUseEvents: boolean; @@ -7822,10 +7828,10 @@ declare namespace ts { updateJSDocReadonlyTag(node: JSDocReadonlyTag, tagName: Identifier | undefined, comment: string | NodeArray | undefined): JSDocReadonlyTag; createJSDocUnknownTag(tagName: Identifier, comment?: string | NodeArray): JSDocUnknownTag; updateJSDocUnknownTag(node: JSDocUnknownTag, tagName: Identifier, comment: string | NodeArray | undefined): JSDocUnknownTag; - createJSDocDeprecatedTag(tagName: Identifier, comment?: string | NodeArray): JSDocDeprecatedTag; - updateJSDocDeprecatedTag(node: JSDocDeprecatedTag, tagName: Identifier, comment?: string | NodeArray): JSDocDeprecatedTag; - createJSDocOverrideTag(tagName: Identifier, comment?: string | NodeArray): JSDocOverrideTag; - updateJSDocOverrideTag(node: JSDocOverrideTag, tagName: Identifier, comment?: string | NodeArray): JSDocOverrideTag; + createJSDocDeprecatedTag(tagName: Identifier | undefined, comment?: string | NodeArray): JSDocDeprecatedTag; + updateJSDocDeprecatedTag(node: JSDocDeprecatedTag, tagName: Identifier | undefined, comment?: string | NodeArray): JSDocDeprecatedTag; + 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; updateJSDocThrowsTag(node: JSDocThrowsTag, tagName: Identifier | undefined, typeExpression: JSDocTypeExpression | undefined, comment?: string | NodeArray | undefined): JSDocThrowsTag; createJSDocSatisfiesTag(tagName: Identifier | undefined, typeExpression: JSDocTypeExpression, comment?: string | NodeArray): JSDocSatisfiesTag; @@ -8192,16 +8198,39 @@ declare namespace ts { /** * A function that accepts and possibly transforms a node. */ - type Visitor = (node: Node) => VisitResult; + type Visitor = (node: TIn) => VisitResult; + /** + * A function that walks a node using the given visitor, lifting node arrays into single nodes, + * returning an node which satisfies the test. + * + * - If the input node is undefined, then the output is undefined. + * - If the visitor returns undefined, then the output is undefined. + * - If the output node is not undefined, then it will satisfy the test function. + * - In order to obtain a return type that is more specific than `Node`, a test + * function _must_ be provided, and that function must be a type predicate. + * + * For the canonical implementation of this type, @see {visitNode}. + */ interface NodeVisitor { - (nodes: T, visitor: Visitor | undefined, test?: (node: Node) => boolean, lift?: (node: readonly Node[]) => T): T; - (nodes: T | undefined, visitor: Visitor | undefined, test?: (node: Node) => boolean, lift?: (node: readonly Node[]) => T): T | undefined; + (node: TIn, visitor: Visitor, TVisited>, test: (node: Node) => node is TOut, lift?: (node: readonly Node[]) => Node): TOut | (TIn & undefined) | (TVisited & undefined); + (node: TIn, visitor: Visitor, TVisited>, test?: (node: Node) => boolean, lift?: (node: readonly Node[]) => Node): Node | (TIn & undefined) | (TVisited & undefined); } + /** + * A function that walks a node array using the given visitor, returning an array whose contents satisfy the test. + * + * - If the input node array is undefined, the output is undefined. + * - If the visitor can return undefined, the node it visits in the array will be reused. + * - If the output node array is not undefined, then its contents will satisfy the test. + * - In order to obtain a return type that is more specific than `NodeArray`, a test + * function _must_ be provided, and that function must be a type predicate. + * + * For the canonical implementation of this type, @see {visitNodes}. + */ interface NodesVisitor { - (nodes: NodeArray, visitor: Visitor | undefined, test?: (node: Node) => boolean, start?: number, count?: number): NodeArray; - (nodes: NodeArray | undefined, visitor: Visitor | undefined, test?: (node: Node) => boolean, start?: number, count?: number): NodeArray | undefined; + | undefined, TOut extends Node>(nodes: TInArray, visitor: Visitor, test: (node: Node) => node is TOut, start?: number, count?: number): NodeArray | (TInArray & undefined); + | undefined>(nodes: TInArray, visitor: Visitor, test?: (node: Node) => boolean, start?: number, count?: number): NodeArray | (TInArray & undefined); } - type VisitResult = T | readonly T[] | undefined; + type VisitResult = T | readonly Node[]; interface Printer { /** * Print a node and its subtree as-is, without any emit transformations. @@ -8415,6 +8444,7 @@ declare namespace ts { } type FileWatcherCallback = (fileName: string, eventKind: FileWatcherEventKind, modifiedTime?: Date) => void; type DirectoryWatcherCallback = (fileName: string) => void; + type BufferEncoding = "ascii" | "utf8" | "utf-8" | "utf16le" | "ucs2" | "ucs-2" | "base64" | "latin1" | "binary" | "hex"; interface System { args: string[]; newLine: string; @@ -8473,8 +8503,8 @@ declare namespace ts { function forEachLeadingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean, state: T) => U, state: T): U | undefined; function forEachTrailingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean) => U): U | undefined; function forEachTrailingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean, state: T) => U, state: T): U | undefined; - function reduceEachLeadingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean, state: T, memo: U) => U, state: T, initial: U): U | undefined; - function reduceEachTrailingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean, state: T, memo: U) => U, state: T, initial: U): U | undefined; + function reduceEachLeadingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean, state: T) => U, state: T, initial: U): U | undefined; + function reduceEachTrailingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean, state: T) => U, state: T, initial: U): U | undefined; function getLeadingCommentRanges(text: string, pos: number): CommentRange[] | undefined; function getTrailingCommentRanges(text: string, pos: number): CommentRange[] | undefined; /** Optionally, get the shebang */ @@ -8553,7 +8583,7 @@ declare namespace ts { function getTypeParameterOwner(d: Declaration): Declaration | undefined; function isParameterPropertyDeclaration(node: Node, parent: Node): node is ParameterPropertyDeclaration; function isEmptyBindingPattern(node: BindingName): node is BindingPattern; - function isEmptyBindingElement(node: BindingElement): boolean; + function isEmptyBindingElement(node: BindingElement | ArrayBindingElement): boolean; function walkUpBindingElementsAndPatterns(binding: BindingElement): VariableDeclaration | ParameterDeclaration; function getCombinedModifierFlags(node: Declaration): ModifierFlags; function getCombinedNodeFlags(node: Node): NodeFlags; @@ -8570,7 +8600,7 @@ declare namespace ts { function getOriginalNode(node: Node): Node; function getOriginalNode(node: Node, nodeTest: (node: Node) => node is T): T; function getOriginalNode(node: Node | undefined): Node | undefined; - function getOriginalNode(node: Node | undefined, nodeTest: (node: Node | undefined) => node is T): T | undefined; + function getOriginalNode(node: Node | undefined, nodeTest: (node: Node) => node is T): T | undefined; /** * Iterates through the parent chain of a node and performs the callback on each parent until the callback * returns a truthy value, then returns that value. @@ -9288,41 +9318,65 @@ declare namespace ts { /** * Visits a Node using the supplied visitor, possibly returning a new Node in its place. * + * - If the input node is undefined, then the output is undefined. + * - If the visitor returns undefined, then the output is undefined. + * - If the output node is not undefined, then it will satisfy the test function. + * - In order to obtain a return type that is more specific than `Node`, a test + * function _must_ be provided, and that function must be a type predicate. + * * @param node The Node to visit. * @param visitor The callback used to visit the Node. * @param test A callback to execute to verify the Node is valid. * @param lift An optional callback to execute to lift a NodeArray into a valid Node. */ - function visitNode(node: T, visitor: Visitor | undefined, test?: (node: Node) => boolean, lift?: (node: readonly Node[]) => T): T; + function visitNode(node: TIn, visitor: Visitor, TVisited>, test: (node: Node) => node is TOut, lift?: (node: readonly Node[]) => Node): TOut | (TIn & undefined) | (TVisited & undefined); /** * Visits a Node using the supplied visitor, possibly returning a new Node in its place. * + * - If the input node is undefined, then the output is undefined. + * - If the visitor returns undefined, then the output is undefined. + * - If the output node is not undefined, then it will satisfy the test function. + * - In order to obtain a return type that is more specific than `Node`, a test + * function _must_ be provided, and that function must be a type predicate. + * * @param node The Node to visit. * @param visitor The callback used to visit the Node. * @param test A callback to execute to verify the Node is valid. * @param lift An optional callback to execute to lift a NodeArray into a valid Node. */ - function visitNode(node: T | undefined, visitor: Visitor | undefined, test?: (node: Node) => boolean, lift?: (node: readonly Node[]) => T): T | undefined; + function visitNode(node: TIn, visitor: Visitor, TVisited>, test?: (node: Node) => boolean, lift?: (node: readonly Node[]) => Node): Node | (TIn & undefined) | (TVisited & undefined); /** * Visits a NodeArray using the supplied visitor, possibly returning a new NodeArray in its place. * + * - If the input node array is undefined, the output is undefined. + * - If the visitor can return undefined, the node it visits in the array will be reused. + * - If the output node array is not undefined, then its contents will satisfy the test. + * - In order to obtain a return type that is more specific than `NodeArray`, a test + * function _must_ be provided, and that function must be a type predicate. + * * @param nodes The NodeArray to visit. * @param visitor The callback used to visit a Node. * @param test A node test to execute for each node. * @param start An optional value indicating the starting offset at which to start visiting. * @param count An optional value indicating the maximum number of nodes to visit. */ - function visitNodes(nodes: NodeArray, visitor: Visitor | undefined, test?: (node: Node) => boolean, start?: number, count?: number): NodeArray; + function visitNodes | undefined, TOut extends Node>(nodes: TInArray, visitor: Visitor, test: (node: Node) => node is TOut, start?: number, count?: number): NodeArray | (TInArray & undefined); /** * Visits a NodeArray using the supplied visitor, possibly returning a new NodeArray in its place. * + * - If the input node array is undefined, the output is undefined. + * - If the visitor can return undefined, the node it visits in the array will be reused. + * - If the output node array is not undefined, then its contents will satisfy the test. + * - In order to obtain a return type that is more specific than `NodeArray`, a test + * function _must_ be provided, and that function must be a type predicate. + * * @param nodes The NodeArray to visit. * @param visitor The callback used to visit a Node. * @param test A node test to execute for each node. * @param start An optional value indicating the starting offset at which to start visiting. * @param count An optional value indicating the maximum number of nodes to visit. */ - function visitNodes(nodes: NodeArray | undefined, visitor: Visitor | undefined, test?: (node: Node) => boolean, start?: number, count?: number): NodeArray | undefined; + function visitNodes | undefined>(nodes: TInArray, visitor: Visitor, test?: (node: Node) => boolean, start?: number, count?: number): NodeArray | (TInArray & undefined); /** * Starts a new lexical environment and visits a statement list, ending the lexical environment * and merging hoisted declarations upon completion. diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index 32b2585c29f7e..6c4dd8cf96b43 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -3887,10 +3887,10 @@ declare namespace ts { updateJSDocReadonlyTag(node: JSDocReadonlyTag, tagName: Identifier | undefined, comment: string | NodeArray | undefined): JSDocReadonlyTag; createJSDocUnknownTag(tagName: Identifier, comment?: string | NodeArray): JSDocUnknownTag; updateJSDocUnknownTag(node: JSDocUnknownTag, tagName: Identifier, comment: string | NodeArray | undefined): JSDocUnknownTag; - createJSDocDeprecatedTag(tagName: Identifier, comment?: string | NodeArray): JSDocDeprecatedTag; - updateJSDocDeprecatedTag(node: JSDocDeprecatedTag, tagName: Identifier, comment?: string | NodeArray): JSDocDeprecatedTag; - createJSDocOverrideTag(tagName: Identifier, comment?: string | NodeArray): JSDocOverrideTag; - updateJSDocOverrideTag(node: JSDocOverrideTag, tagName: Identifier, comment?: string | NodeArray): JSDocOverrideTag; + createJSDocDeprecatedTag(tagName: Identifier | undefined, comment?: string | NodeArray): JSDocDeprecatedTag; + updateJSDocDeprecatedTag(node: JSDocDeprecatedTag, tagName: Identifier | undefined, comment?: string | NodeArray): JSDocDeprecatedTag; + 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; updateJSDocThrowsTag(node: JSDocThrowsTag, tagName: Identifier | undefined, typeExpression: JSDocTypeExpression | undefined, comment?: string | NodeArray | undefined): JSDocThrowsTag; createJSDocSatisfiesTag(tagName: Identifier | undefined, typeExpression: JSDocTypeExpression, comment?: string | NodeArray): JSDocSatisfiesTag; @@ -4257,16 +4257,39 @@ declare namespace ts { /** * A function that accepts and possibly transforms a node. */ - type Visitor = (node: Node) => VisitResult; + type Visitor = (node: TIn) => VisitResult; + /** + * A function that walks a node using the given visitor, lifting node arrays into single nodes, + * returning an node which satisfies the test. + * + * - If the input node is undefined, then the output is undefined. + * - If the visitor returns undefined, then the output is undefined. + * - If the output node is not undefined, then it will satisfy the test function. + * - In order to obtain a return type that is more specific than `Node`, a test + * function _must_ be provided, and that function must be a type predicate. + * + * For the canonical implementation of this type, @see {visitNode}. + */ interface NodeVisitor { - (nodes: T, visitor: Visitor | undefined, test?: (node: Node) => boolean, lift?: (node: readonly Node[]) => T): T; - (nodes: T | undefined, visitor: Visitor | undefined, test?: (node: Node) => boolean, lift?: (node: readonly Node[]) => T): T | undefined; + (node: TIn, visitor: Visitor, TVisited>, test: (node: Node) => node is TOut, lift?: (node: readonly Node[]) => Node): TOut | (TIn & undefined) | (TVisited & undefined); + (node: TIn, visitor: Visitor, TVisited>, test?: (node: Node) => boolean, lift?: (node: readonly Node[]) => Node): Node | (TIn & undefined) | (TVisited & undefined); } + /** + * A function that walks a node array using the given visitor, returning an array whose contents satisfy the test. + * + * - If the input node array is undefined, the output is undefined. + * - If the visitor can return undefined, the node it visits in the array will be reused. + * - If the output node array is not undefined, then its contents will satisfy the test. + * - In order to obtain a return type that is more specific than `NodeArray`, a test + * function _must_ be provided, and that function must be a type predicate. + * + * For the canonical implementation of this type, @see {visitNodes}. + */ interface NodesVisitor { - (nodes: NodeArray, visitor: Visitor | undefined, test?: (node: Node) => boolean, start?: number, count?: number): NodeArray; - (nodes: NodeArray | undefined, visitor: Visitor | undefined, test?: (node: Node) => boolean, start?: number, count?: number): NodeArray | undefined; + | undefined, TOut extends Node>(nodes: TInArray, visitor: Visitor, test: (node: Node) => node is TOut, start?: number, count?: number): NodeArray | (TInArray & undefined); + | undefined>(nodes: TInArray, visitor: Visitor, test?: (node: Node) => boolean, start?: number, count?: number): NodeArray | (TInArray & undefined); } - type VisitResult = T | readonly T[] | undefined; + type VisitResult = T | readonly Node[]; interface Printer { /** * Print a node and its subtree as-is, without any emit transformations. @@ -4480,6 +4503,7 @@ declare namespace ts { } type FileWatcherCallback = (fileName: string, eventKind: FileWatcherEventKind, modifiedTime?: Date) => void; type DirectoryWatcherCallback = (fileName: string) => void; + type BufferEncoding = "ascii" | "utf8" | "utf-8" | "utf16le" | "ucs2" | "ucs-2" | "base64" | "latin1" | "binary" | "hex"; interface System { args: string[]; newLine: string; @@ -4538,8 +4562,8 @@ declare namespace ts { function forEachLeadingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean, state: T) => U, state: T): U | undefined; function forEachTrailingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean) => U): U | undefined; function forEachTrailingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean, state: T) => U, state: T): U | undefined; - function reduceEachLeadingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean, state: T, memo: U) => U, state: T, initial: U): U | undefined; - function reduceEachTrailingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean, state: T, memo: U) => U, state: T, initial: U): U | undefined; + function reduceEachLeadingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean, state: T) => U, state: T, initial: U): U | undefined; + function reduceEachTrailingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean, state: T) => U, state: T, initial: U): U | undefined; function getLeadingCommentRanges(text: string, pos: number): CommentRange[] | undefined; function getTrailingCommentRanges(text: string, pos: number): CommentRange[] | undefined; /** Optionally, get the shebang */ @@ -4618,7 +4642,7 @@ declare namespace ts { function getTypeParameterOwner(d: Declaration): Declaration | undefined; function isParameterPropertyDeclaration(node: Node, parent: Node): node is ParameterPropertyDeclaration; function isEmptyBindingPattern(node: BindingName): node is BindingPattern; - function isEmptyBindingElement(node: BindingElement): boolean; + function isEmptyBindingElement(node: BindingElement | ArrayBindingElement): boolean; function walkUpBindingElementsAndPatterns(binding: BindingElement): VariableDeclaration | ParameterDeclaration; function getCombinedModifierFlags(node: Declaration): ModifierFlags; function getCombinedNodeFlags(node: Node): NodeFlags; @@ -4635,7 +4659,7 @@ declare namespace ts { function getOriginalNode(node: Node): Node; function getOriginalNode(node: Node, nodeTest: (node: Node) => node is T): T; function getOriginalNode(node: Node | undefined): Node | undefined; - function getOriginalNode(node: Node | undefined, nodeTest: (node: Node | undefined) => node is T): T | undefined; + function getOriginalNode(node: Node | undefined, nodeTest: (node: Node) => node is T): T | undefined; /** * Iterates through the parent chain of a node and performs the callback on each parent until the callback * returns a truthy value, then returns that value. @@ -5353,41 +5377,65 @@ declare namespace ts { /** * Visits a Node using the supplied visitor, possibly returning a new Node in its place. * + * - If the input node is undefined, then the output is undefined. + * - If the visitor returns undefined, then the output is undefined. + * - If the output node is not undefined, then it will satisfy the test function. + * - In order to obtain a return type that is more specific than `Node`, a test + * function _must_ be provided, and that function must be a type predicate. + * * @param node The Node to visit. * @param visitor The callback used to visit the Node. * @param test A callback to execute to verify the Node is valid. * @param lift An optional callback to execute to lift a NodeArray into a valid Node. */ - function visitNode(node: T, visitor: Visitor | undefined, test?: (node: Node) => boolean, lift?: (node: readonly Node[]) => T): T; + function visitNode(node: TIn, visitor: Visitor, TVisited>, test: (node: Node) => node is TOut, lift?: (node: readonly Node[]) => Node): TOut | (TIn & undefined) | (TVisited & undefined); /** * Visits a Node using the supplied visitor, possibly returning a new Node in its place. * + * - If the input node is undefined, then the output is undefined. + * - If the visitor returns undefined, then the output is undefined. + * - If the output node is not undefined, then it will satisfy the test function. + * - In order to obtain a return type that is more specific than `Node`, a test + * function _must_ be provided, and that function must be a type predicate. + * * @param node The Node to visit. * @param visitor The callback used to visit the Node. * @param test A callback to execute to verify the Node is valid. * @param lift An optional callback to execute to lift a NodeArray into a valid Node. */ - function visitNode(node: T | undefined, visitor: Visitor | undefined, test?: (node: Node) => boolean, lift?: (node: readonly Node[]) => T): T | undefined; + function visitNode(node: TIn, visitor: Visitor, TVisited>, test?: (node: Node) => boolean, lift?: (node: readonly Node[]) => Node): Node | (TIn & undefined) | (TVisited & undefined); /** * Visits a NodeArray using the supplied visitor, possibly returning a new NodeArray in its place. * + * - If the input node array is undefined, the output is undefined. + * - If the visitor can return undefined, the node it visits in the array will be reused. + * - If the output node array is not undefined, then its contents will satisfy the test. + * - In order to obtain a return type that is more specific than `NodeArray`, a test + * function _must_ be provided, and that function must be a type predicate. + * * @param nodes The NodeArray to visit. * @param visitor The callback used to visit a Node. * @param test A node test to execute for each node. * @param start An optional value indicating the starting offset at which to start visiting. * @param count An optional value indicating the maximum number of nodes to visit. */ - function visitNodes(nodes: NodeArray, visitor: Visitor | undefined, test?: (node: Node) => boolean, start?: number, count?: number): NodeArray; + function visitNodes | undefined, TOut extends Node>(nodes: TInArray, visitor: Visitor, test: (node: Node) => node is TOut, start?: number, count?: number): NodeArray | (TInArray & undefined); /** * Visits a NodeArray using the supplied visitor, possibly returning a new NodeArray in its place. * + * - If the input node array is undefined, the output is undefined. + * - If the visitor can return undefined, the node it visits in the array will be reused. + * - If the output node array is not undefined, then its contents will satisfy the test. + * - In order to obtain a return type that is more specific than `NodeArray`, a test + * function _must_ be provided, and that function must be a type predicate. + * * @param nodes The NodeArray to visit. * @param visitor The callback used to visit a Node. * @param test A node test to execute for each node. * @param start An optional value indicating the starting offset at which to start visiting. * @param count An optional value indicating the maximum number of nodes to visit. */ - function visitNodes(nodes: NodeArray | undefined, visitor: Visitor | undefined, test?: (node: Node) => boolean, start?: number, count?: number): NodeArray | undefined; + function visitNodes | undefined>(nodes: TInArray, visitor: Visitor, test?: (node: Node) => boolean, start?: number, count?: number): NodeArray | (TInArray & undefined); /** * Starts a new lexical environment and visits a statement list, ending the lexical environment * and merging hoisted declarations upon completion.