diff --git a/build/logic/generate.ts b/build/logic/generate.ts index 39748c2..ea8d0b1 100644 --- a/build/logic/generate.ts +++ b/build/logic/generate.ts @@ -18,7 +18,7 @@ export function generate( tsLibDir: string, targetFile: string, sourceFile: string, - { emitOriginalAsComment = false, emitNoDefaultLib = false }: GenerateOptions + { emitOriginalAsComment = false, emitNoDefaultLib = false }: GenerateOptions, ): string | undefined { const tsLibFile = path.join(tsLibDir, sourceFile); const originalProgram = ts.createProgram([tsLibFile], {}); @@ -60,7 +60,7 @@ export function generate( if (!ts.isInterfaceDeclaration(statement)) { // Find the replacement target of same kind. const replacementTargetOfSameKind = replacementTarget.flatMap((target) => - target.type === "non-interface" ? [target] : [] + target.type === "non-interface" ? [target] : [], ); if (replacementTargetOfSameKind.length === 0) { result += statement.getFullText(originalFile); @@ -79,7 +79,7 @@ export function generate( continue; } const replaceInterfaces = replacementTarget.flatMap((target) => - target.type === "interface" ? [target] : [] + target.type === "interface" ? [target] : [], ); if ( replaceInterfaces.some( @@ -88,8 +88,8 @@ export function generate( statement, originalFile, target.originalStatement, - target.sourceFile - ) + target.sourceFile, + ), ) ) { // This needs to be a full replacement @@ -197,7 +197,7 @@ type ReplacementTarget = ( */ function scanBetterFile( printer: ts.Printer, - targetFile: string + targetFile: string, ): Map { const replacementTargets = new Map(); { @@ -224,7 +224,7 @@ function scanBetterFile( const memberName = member.name?.getText(betterFile) ?? ""; upsert(members, memberName, (members = []) => { const leadingSpacesMatch = /^\s*/.exec( - member.getFullText(betterFile) + member.getFullText(betterFile), ); const leadingSpaces = leadingSpacesMatch !== null ? leadingSpacesMatch[0] : ""; @@ -235,7 +235,7 @@ function scanBetterFile( printer.printNode( ts.EmitHint.Unspecified, member, - betterFile + betterFile, ), }); return members; @@ -274,7 +274,7 @@ function isPartialReplacement( interfaceDecl: ts.InterfaceDeclaration, originalFile: ts.SourceFile, replacementDecl: ts.InterfaceDeclaration, - betterFile: ts.SourceFile + betterFile: ts.SourceFile, ): boolean { // Compare type parameters and herigate using full text. if ( @@ -334,7 +334,7 @@ function printInterface( printer: ts.Printer, originalNode: ts.InterfaceDeclaration, members: readonly { text: string }[], - originalSourceFile: ts.SourceFile + originalSourceFile: ts.SourceFile, ): string { let result = originalNode .getFullText(originalSourceFile) @@ -343,27 +343,27 @@ function printInterface( result += printer.printNode( ts.EmitHint.Unspecified, mod, - originalSourceFile + originalSourceFile, ); } result += "interface "; result += printer.printNode( ts.EmitHint.Unspecified, originalNode.name, - originalSourceFile + originalSourceFile, ); if (originalNode.typeParameters) { result += printer.printList( ts.ListFormat.TypeParameters, originalNode.typeParameters, - originalSourceFile + originalSourceFile, ); } if (originalNode.heritageClauses) { result += printer.printList( ts.ListFormat.HeritageClauses, originalNode.heritageClauses, - originalSourceFile + originalSourceFile, ); } result += "{\n"; @@ -402,7 +402,7 @@ function commentOut(code: string): string { function replaceAliases( statement: ts.Statement, - typeMap: Map + typeMap: Map, ): ts.Statement { if (typeMap.size === 0) return statement; return ts.transform(statement, [ @@ -416,7 +416,7 @@ function replaceAliases( return ts.factory.updateTypeReferenceNode( node, ts.factory.createIdentifier(replacementType), - node.typeArguments + node.typeArguments, ); } return ts.visitEachChild(node, visitor, context); diff --git a/build/logic/getLibFiles.ts b/build/logic/getLibFiles.ts index 74b02e7..47f986a 100644 --- a/build/logic/getLibFiles.ts +++ b/build/logic/getLibFiles.ts @@ -18,6 +18,6 @@ export const getLibFiles = async () => { const sourceFile = `${lib}.d.ts`; const targetFile = paths[lib] || `lib.${sourceFile}`; return [targetFile, sourceFile]; - }) + }), ); }; diff --git a/build/package.ts b/build/package.ts index 6625b52..b28f3d7 100644 --- a/build/package.ts +++ b/build/package.ts @@ -22,7 +22,7 @@ async function main() { const packageTemplateFiles = await readdir(templateDir); const libFiles = (await readdir(libDir)).filter((libFile) => - /\.d\.ts$/.test(libFile) + /\.d\.ts$/.test(libFile), ); const packageNames = new Set(); @@ -49,7 +49,7 @@ async function main() { const packageJsonPath = path.join( packageDir, packageName, - "package.json" + "package.json", ); await writeToPackageJson(packageJsonPath, () => ({ name: toScopedPackageName(packageName), @@ -73,7 +73,7 @@ async function main() { // copy root README to main package await writeFile( path.join(mainPackageDir, "README.md"), - await readFile(path.join(projectDir, "README.md")) + await readFile(path.join(projectDir, "README.md")), ); // update package.json const packageJsonPath = path.join(mainPackageDir, "package.json"); @@ -85,13 +85,13 @@ async function main() { [...packageNames].map((packageName) => [ `@typescript/lib-${packageName}`, `npm:${toScopedPackageName(packageName)}@${version}`, - ]) + ]), ), })); // prepare symlink to dist await symlink( path.join(projectDir, "dist"), - path.join(mainPackageDir, "dist") + path.join(mainPackageDir, "dist"), ); } // update package.json in "tests" folder @@ -105,9 +105,9 @@ async function main() { `@typescript/lib-${packageName}`, `file:${path.relative( path.dirname(packageJsonPath), - path.join(packageDir, packageName) + path.join(packageDir, packageName), )}`, - ]) + ]), ), }, })); @@ -119,12 +119,12 @@ async function main() { const filePath = path.join(templateDir, file); const targetPath = path.join(dir, file); return writeFile(targetPath, await readFile(filePath)); - }) + }), ); } async function writeToPackageJson( packageJsonPath: string, - updates: (original: any) => Record + updates: (original: any) => Record, ) { const original = JSON.parse(await readFile(packageJsonPath, "utf-8")); return writeFile( @@ -135,8 +135,8 @@ async function main() { ...updates(original), }, null, - 2 - ) + "\n" + 2, + ) + "\n", ); } function toScopedPackageName(packageName: string) { diff --git a/build/util/alias.ts b/build/util/alias.ts index f7bbf6a..ba731eb 100644 --- a/build/util/alias.ts +++ b/build/util/alias.ts @@ -27,7 +27,7 @@ export const alias = new Map( [originalType, replacement], [`${originalType}Constructor`, `${replacement}Constructor`], ]), - ]) + ]), ), ], [ @@ -39,8 +39,8 @@ export const alias = new Map( [originalType, replacement], [`${originalType}Constructor`, `${replacement}Constructor`], ]), - ]) + ]), ), ], - ]) + ]), ); diff --git a/build/util/upsert.ts b/build/util/upsert.ts index 93f886d..7913dce 100644 --- a/build/util/upsert.ts +++ b/build/util/upsert.ts @@ -1,7 +1,7 @@ export function upsert( map: Map, key: K, - update: (value: V | undefined) => V + update: (value: V | undefined) => V, ) { const value = map.get(key); map.set(key, update(value)); diff --git a/lib/lib.es2015.collection.d.ts b/lib/lib.es2015.collection.d.ts index bcceed4..2f2871c 100644 --- a/lib/lib.es2015.collection.d.ts +++ b/lib/lib.es2015.collection.d.ts @@ -4,7 +4,7 @@ interface Map { */ forEach( callbackfn: (this: This, value: V, key: K, map: this) => void, - thisArg?: This + thisArg?: This, ): void; } @@ -15,7 +15,7 @@ interface MapConstructor { interface WeakMapConstructor { new ( - entries?: readonly (readonly [K, V])[] | null + entries?: readonly (readonly [K, V])[] | null, ): WeakMap; readonly prototype: WeakMap; } @@ -23,7 +23,7 @@ interface WeakMapConstructor { interface ReadonlyMap { forEach( callbackfn: (this: This, value: V, key: K, map: this) => void, - thisArg?: This + thisArg?: This, ): void; } @@ -33,7 +33,7 @@ interface Set { */ forEach( callbackfn: (this: This, value: T, value2: T, set: this) => void, - thisArg?: This + thisArg?: This, ): void; } @@ -45,6 +45,6 @@ interface SetConstructor { interface ReadonlySet { forEach( callbackfn: (this: This, value: T, value2: T, set: this) => void, - thisArg?: This + thisArg?: This, ): void; } diff --git a/lib/lib.es2015.core.d.ts b/lib/lib.es2015.core.d.ts index a07223f..b047181 100644 --- a/lib/lib.es2015.core.d.ts +++ b/lib/lib.es2015.core.d.ts @@ -10,7 +10,7 @@ interface Array { */ find( predicate: (this: This, value: T, index: number, obj: this) => value is S, - thisArg?: This + thisArg?: This, ): S | undefined; /** @@ -24,7 +24,7 @@ interface Array { */ find( predicate: (this: This, value: T, index: number, obj: this) => boolean, - thisArg?: This + thisArg?: This, ): T | undefined; /** @@ -38,7 +38,7 @@ interface Array { */ findIndex( predicate: (this: This, value: T, index: number, obj: this) => boolean, - thisArg?: This + thisArg?: This, ): number; } @@ -58,7 +58,7 @@ interface ArrayConstructor { from( source: ArrayLike, mapfn: (this: This, v: T, k: number) => U, - thisArg?: This + thisArg?: This, ): U[]; } @@ -114,7 +114,7 @@ interface ReadonlyArray { */ find( predicate: (this: This, value: T, index: number, obj: this) => value is S, - thisArg?: This + thisArg?: This, ): S | undefined; /** @@ -128,7 +128,7 @@ interface ReadonlyArray { */ find( predicate: (this: This, value: T, index: number, obj: this) => boolean, - thisArg?: This + thisArg?: This, ): T | undefined; /** @@ -142,7 +142,7 @@ interface ReadonlyArray { */ findIndex( predicate: (this: This, value: T, index: number, obj: this) => boolean, - thisArg?: This + thisArg?: This, ): number; } diff --git a/lib/lib.es2015.iterable.d.ts b/lib/lib.es2015.iterable.d.ts index 4da8786..65ac111 100644 --- a/lib/lib.es2015.iterable.d.ts +++ b/lib/lib.es2015.iterable.d.ts @@ -25,7 +25,7 @@ interface ArrayConstructor { from( iterable: Iterable | ArrayLike, mapfn: (this: This, v: T, k: number) => U, - thisArg?: This + thisArg?: This, ): U[]; } @@ -71,6 +71,6 @@ interface TypedNumberArrayConstructor { from( iterable: Iterable | ArrayLike, mapfn: (this: This, v: T, k: number) => number, - thisArg?: This + thisArg?: This, ): TypedNumberArray; } diff --git a/lib/lib.es2015.promise.d.ts b/lib/lib.es2015.promise.d.ts index 6c412f6..ee6ea53 100644 --- a/lib/lib.es2015.promise.d.ts +++ b/lib/lib.es2015.promise.d.ts @@ -10,8 +10,8 @@ interface PromiseConstructor { resolve: undefined extends T ? (value?: T | PromiseLike) => void : (value: T | PromiseLike) => void, - reject: (reason?: any) => void - ) => void + reject: (reason?: any) => void, + ) => void, ): Promise; /** diff --git a/lib/lib.es2015.proxy.d.ts b/lib/lib.es2015.proxy.d.ts index 8b020a8..1b220aa 100644 --- a/lib/lib.es2015.proxy.d.ts +++ b/lib/lib.es2015.proxy.d.ts @@ -17,12 +17,17 @@ interface ProxyHandler { * @param receiver The proxy or an object that inherits from the proxy. */ get?(target: T, p: string | symbol, receiver: unknown): any; - /** + /** * A trap for setting a property value. * @param target The original object which is being proxied. * @param p The name or `Symbol` of the property to set. * @param receiver The object to which the assignment was originally directed. * @returns A `Boolean` indicating whether or not the property was set. */ - set?(target: T, p: string | symbol, value: unknown, receiver: unknown): boolean; + set?( + target: T, + p: string | symbol, + value: unknown, + receiver: unknown, + ): boolean; } diff --git a/lib/lib.es2015.reflect.d.ts b/lib/lib.es2015.reflect.d.ts index 729a194..15e3584 100644 --- a/lib/lib.es2015.reflect.d.ts +++ b/lib/lib.es2015.reflect.d.ts @@ -7,9 +7,9 @@ declare namespace Reflect { * @param argumentsList An array of argument values to be passed to the function. */ function apply( - target: (this: T, ...args: A) => R, - thisArgument: T, - argumentsList: Readonly, + target: (this: T, ...args: A) => R, + thisArgument: T, + argumentsList: Readonly, ): R; /** * Constructs the target with the elements of specified array as the arguments @@ -19,9 +19,9 @@ declare namespace Reflect { * @param newTarget The constructor to be used as the `new.target` object. */ function construct( - target: new (...args: A) => R, - argumentsList: Readonly, - newTarget?: new (...args: any) => any, + target: new (...args: A) => R, + argumentsList: Readonly, + newTarget?: new (...args: any) => any, ): R; /** * Adds a property to an object, or modifies attributes of an existing property. @@ -30,7 +30,11 @@ declare namespace Reflect { * @param propertyKey The property name. * @param attributes Descriptor for the property. It can be for a data property or an accessor property. */ - function defineProperty(target: object, propertyKey: PropertyKey, attributes: PropertyDescriptor & ThisType): boolean; + function defineProperty( + target: object, + propertyKey: PropertyKey, + attributes: PropertyDescriptor & ThisType, + ): boolean; /** * Removes a property from an object, equivalent to `delete target[propertyKey]`, * except it won't throw if `target[propertyKey]` is non-configurable. @@ -48,7 +52,7 @@ declare namespace Reflect { function get( target: T, propertyKey: P, - receiver?: unknown + receiver?: unknown, ): P extends keyof T ? T[P] : unknown; /** * Gets the own property descriptor of the specified object. @@ -57,8 +61,8 @@ declare namespace Reflect { * @param propertyKey The property name. */ function getOwnPropertyDescriptor( - target: T, - propertyKey: P, + target: T, + propertyKey: P, ): TypedPropertyDescriptor

| undefined; /** * Returns the prototype of an object. @@ -96,12 +100,17 @@ declare namespace Reflect { * if `target[propertyKey]` is an accessor property. */ function set( - target: T, - propertyKey: P, - value: P extends keyof T ? T[P] : any, - receiver?: any, + target: T, + propertyKey: P, + value: P extends keyof T ? T[P] : any, + receiver?: any, + ): boolean; + function set( + target: object, + propertyKey: PropertyKey, + value: any, + receiver?: any, ): boolean; - function set(target: object, propertyKey: PropertyKey, value: any, receiver?: any): boolean; /** * Sets the prototype of a specified object o to object proto or null. * @param target The object to change its prototype. diff --git a/lib/lib.es2015.symbol.wellknown.d.ts b/lib/lib.es2015.symbol.wellknown.d.ts index 29532fb..c0ae82c 100644 --- a/lib/lib.es2015.symbol.wellknown.d.ts +++ b/lib/lib.es2015.symbol.wellknown.d.ts @@ -21,7 +21,7 @@ interface RegExp { // TODO: could be improved, but blocked by issue: // https://github.com/microsoft/TypeScript/issues/45972 ...rest: (string | number)[] - ) => string + ) => string, ): string; } @@ -35,7 +35,7 @@ interface String { searchValue: { [Symbol.replace](string: string, replaceValue: string): string; }, - replaceValue: string + replaceValue: string, ): string; /** @@ -47,9 +47,9 @@ interface String { searchValue: { [Symbol.replace]( string: string, - replacer: (substring: string, ...rest: (string | number)[]) => string + replacer: (substring: string, ...rest: (string | number)[]) => string, ): string; }, - replacer: (substring: string, ...rest: (string | number)[]) => string + replacer: (substring: string, ...rest: (string | number)[]) => string, ): string; } diff --git a/lib/lib.es2017.object.d.ts b/lib/lib.es2017.object.d.ts index b4c2f70..9cb187d 100644 --- a/lib/lib.es2017.object.d.ts +++ b/lib/lib.es2017.object.d.ts @@ -36,7 +36,7 @@ interface ObjectConstructor { * @param o Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object. */ getOwnPropertyDescriptors( - o: T + o: T, ): { [P in keyof T]: TypedPropertyDescriptor; } & { diff --git a/lib/lib.es2018.asyncgenerator.d.ts b/lib/lib.es2018.asyncgenerator.d.ts index 2065350..357aadc 100644 --- a/lib/lib.es2018.asyncgenerator.d.ts +++ b/lib/lib.es2018.asyncgenerator.d.ts @@ -3,7 +3,7 @@ interface AsyncGenerator // NOTE: 'next' is defined using a tuple to ensure we report the correct assignability errors in all places. next(...args: [] | [TNext]): Promise>; return( - value: TReturn | PromiseLike + value: TReturn | PromiseLike, ): Promise>; throw(e: any): Promise>; [Symbol.asyncIterator](): AsyncGenerator; diff --git a/lib/lib.es2018.asynciterable.d.ts b/lib/lib.es2018.asynciterable.d.ts index 2b7ceb8..382404c 100644 --- a/lib/lib.es2018.asynciterable.d.ts +++ b/lib/lib.es2018.asynciterable.d.ts @@ -2,7 +2,7 @@ interface AsyncIterator { // NOTE: 'next' is defined using a tuple to ensure we report the correct assignability errors in all places. next(...args: [] | [TNext]): Promise>; return?( - value?: TReturn | PromiseLike + value?: TReturn | PromiseLike, ): Promise>; throw?(e?: any): Promise>; } diff --git a/lib/lib.es2018.promise.d.ts b/lib/lib.es2018.promise.d.ts index b279d07..ab77dc3 100644 --- a/lib/lib.es2018.promise.d.ts +++ b/lib/lib.es2018.promise.d.ts @@ -9,6 +9,6 @@ interface Promise { * @returns A Promise for the completion of the callback. */ finally( - onfinally?: (() => U | PromiseLike) | null | undefined + onfinally?: (() => U | PromiseLike) | null | undefined, ): Promise; } diff --git a/lib/lib.es2019.object.d.ts b/lib/lib.es2019.object.d.ts index d212636..aedbfe6 100644 --- a/lib/lib.es2019.object.d.ts +++ b/lib/lib.es2019.object.d.ts @@ -4,6 +4,6 @@ interface ObjectConstructor { * @param entries An iterable object that contains key-value entries for properties and methods. */ fromEntries( - entries: Iterable + entries: Iterable, ): Record; } diff --git a/lib/lib.es2020.bigint.d.ts b/lib/lib.es2020.bigint.d.ts index bd161ab..1e6c041 100644 --- a/lib/lib.es2020.bigint.d.ts +++ b/lib/lib.es2020.bigint.d.ts @@ -12,9 +12,9 @@ interface TypedBigIntArray { this: This, value: bigint, index: number, - array: this + array: this, ) => boolean, - thisArg?: This + thisArg?: This, ): boolean; /** * Returns the elements of an array that meet the condition specified in a callback function. @@ -28,9 +28,9 @@ interface TypedBigIntArray { this: This, value: bigint, index: number, - array: this + array: this, ) => boolean, - thisArg?: This + thisArg?: This, ): TypedBigIntArray; /** * Returns the value of the first element in the array where predicate is true, and undefined @@ -46,9 +46,9 @@ interface TypedBigIntArray { this: This, value: bigint, index: number, - array: this + array: this, ) => boolean, - thisArg?: This + thisArg?: This, ): bigint | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -64,9 +64,9 @@ interface TypedBigIntArray { this: This, value: bigint, index: number, - array: this + array: this, ) => boolean, - thisArg?: This + thisArg?: This, ): number; /** * Performs the specified action for each element in an array. @@ -77,7 +77,7 @@ interface TypedBigIntArray { */ forEach( callbackfn: (this: This, value: bigint, index: number, array: this) => void, - thisArg?: This + thisArg?: This, ): void; /** * Calls a defined callback function on each element of an array, and returns an array that @@ -92,9 +92,9 @@ interface TypedBigIntArray { this: This, value: bigint, index: number, - array: this + array: this, ) => bigint, - thisArg?: This + thisArg?: This, ): TypedBigIntArray; /** * Calls the specified callback function for all the elements in an array. The return value of @@ -108,8 +108,8 @@ interface TypedBigIntArray { previousValue: bigint | U, currentValue: bigint, currentIndex: number, - array: this - ) => U + array: this, + ) => U, ): bigint | U; /** * Calls the specified callback function for all the elements in an array. The return value of @@ -126,9 +126,9 @@ interface TypedBigIntArray { previousValue: U, currentValue: bigint, currentIndex: number, - array: this + array: this, ) => U, - initialValue: U + initialValue: U, ): U; /** * Calls the specified callback function for all the elements in an array, in descending order. @@ -142,8 +142,8 @@ interface TypedBigIntArray { previousValue: bigint | U, currentValue: bigint, currentIndex: number, - array: this - ) => U + array: this, + ) => U, ): bigint | U; /** * Calls the specified callback function for all the elements in an array, in descending order. @@ -160,9 +160,9 @@ interface TypedBigIntArray { previousValue: U, currentValue: bigint, currentIndex: number, - array: this + array: this, ) => U, - initialValue: U + initialValue: U, ): U; /** * Determines whether the specified callback function returns true for any element of an array. @@ -177,9 +177,9 @@ interface TypedBigIntArray { this: This, value: bigint, index: number, - array: this + array: this, ) => boolean, - thisArg?: This + thisArg?: This, ): boolean; } @@ -198,6 +198,6 @@ interface TypedBigIntArrayConstructor { from( arrayLike: Iterable | ArrayLike, mapfn: (this: This, v: T, k: number) => bigint, - thisArg?: This + thisArg?: This, ): TypedBigIntArray; } diff --git a/lib/lib.es2020.promise.d.ts b/lib/lib.es2020.promise.d.ts index 641402c..f7ed87d 100644 --- a/lib/lib.es2020.promise.d.ts +++ b/lib/lib.es2020.promise.d.ts @@ -10,7 +10,7 @@ interface PromiseConstructor { * @returns A new Promise. */ allSettled( - values: T + values: T, ): Promise<{ -readonly [P in keyof T]: PromiseSettledResult> }>; /** @@ -20,6 +20,6 @@ interface PromiseConstructor { * @returns A new Promise. */ allSettled( - values: Iterable + values: Iterable, ): Promise>[]>; } diff --git a/lib/lib.es2021.promise.d.ts b/lib/lib.es2021.promise.d.ts index a42bd17..9cd2aea 100644 --- a/lib/lib.es2021.promise.d.ts +++ b/lib/lib.es2021.promise.d.ts @@ -12,7 +12,7 @@ interface PromiseConstructor { * @returns A new Promise. */ any( - values: T + values: T, ): Promise>; /** diff --git a/lib/lib.es2021.string.d.ts b/lib/lib.es2021.string.d.ts index 03f3d7f..ecf1e6b 100644 --- a/lib/lib.es2021.string.d.ts +++ b/lib/lib.es2021.string.d.ts @@ -18,7 +18,7 @@ interface String { // TODO: could be improved, but blocked by issue: // https://github.com/microsoft/TypeScript/issues/45972 ...rest: (string | number)[] - ) => string + ) => string, ): string; /** @@ -30,7 +30,7 @@ interface String { searchValue: { [Symbol.replace](string: string, replaceValue: string): string; }, - replaceValue: string + replaceValue: string, ): string; /** @@ -42,9 +42,9 @@ interface String { searchValue: { [Symbol.replace]( string: string, - replacer: (substring: string, ...rest: (string | number)[]) => string + replacer: (substring: string, ...rest: (string | number)[]) => string, ): string; }, - replacer: (substring: string, ...rest: (string | number)[]) => string + replacer: (substring: string, ...rest: (string | number)[]) => string, ): string; } diff --git a/lib/lib.es2022.object.d.ts b/lib/lib.es2022.object.d.ts index 77ff9ae..5deead1 100644 --- a/lib/lib.es2022.object.d.ts +++ b/lib/lib.es2022.object.d.ts @@ -6,15 +6,15 @@ interface ObjectConstructor { */ hasOwn( o: Obj, - v: Key + v: Key, ): o is Obj & (string extends Key ? {} : number extends Key - ? {} - : symbol extends Key - ? {} - : Key extends PropertyKey - ? { [key in Key]: unknown } - : {}); + ? {} + : symbol extends Key + ? {} + : Key extends PropertyKey + ? { [key in Key]: unknown } + : {}); } diff --git a/lib/lib.es5.d.ts b/lib/lib.es5.d.ts index 84f7346..941891c 100644 --- a/lib/lib.es5.d.ts +++ b/lib/lib.es5.d.ts @@ -26,17 +26,17 @@ interface Object { */ hasOwnProperty( this: Obj, - v: Key + v: Key, ): this is Obj & (string extends Key ? {} : number extends Key - ? {} - : symbol extends Key - ? {} - : Key extends PropertyKey - ? { [key in Key]: unknown } - : {}); + ? {} + : symbol extends Key + ? {} + : Key extends PropertyKey + ? { [key in Key]: unknown } + : {}); } interface ObjectConstructor { @@ -58,7 +58,7 @@ interface ObjectConstructor { */ getOwnPropertyDescriptor( o: {}, - p: PropertyKey + p: PropertyKey, ): PropertyDescriptor | undefined; /** @@ -87,15 +87,15 @@ interface ObjectConstructor { */ create>( o: O, - properties: P & ThisType + properties: P & ThisType, ): { [K in keyof (O & P)]: P[K] extends { value: infer V } ? V : P[K] extends { get: () => infer V } - ? V - : K extends keyof O - ? O[K] - : unknown; + ? V + : K extends keyof O + ? O[K] + : unknown; }; /** @@ -105,13 +105,13 @@ interface ObjectConstructor { */ create

>( o: null, - properties: P & ThisType + properties: P & ThisType, ): { [K in keyof P]: P[K] extends { value: infer V } ? V : P[K] extends { get: () => infer V } - ? V - : unknown; + ? V + : unknown; }; /** @@ -123,19 +123,19 @@ interface ObjectConstructor { defineProperty< O extends object, P extends PropertyKey, - D extends PropertyDescriptor + D extends PropertyDescriptor, >( o: O, p: P, - attributes: D & ThisType + attributes: D & ThisType, ): O & (P extends PropertyKey // required to make P distributive ? { [K in P]: D extends { value: infer V } ? V : D extends { get: () => infer V } - ? V - : unknown; + ? V + : unknown; } : unknown); @@ -146,18 +146,18 @@ interface ObjectConstructor { */ defineProperties< O extends object, - P extends Record + P extends Record, >( o: O, - properties: P & ThisType + properties: P & ThisType, ): { [K in keyof (O & P)]: P[K] extends { value: infer V } ? V : P[K] extends { get: () => infer V } - ? V - : K extends keyof O - ? O[K] - : unknown; + ? V + : K extends keyof O + ? O[K] + : unknown; }; } @@ -227,7 +227,7 @@ interface String { // TODO: could be improved, but blocked by issue: // https://github.com/microsoft/TypeScript/issues/45972 ...rest: (string | number)[] - ) => string + ) => string, ): string; } @@ -262,8 +262,8 @@ interface JSON { reviver: ( this: JSONHolder, key: K, - value: JSONValueF - ) => A + value: JSONValueF, + ) => A, ): A; /** * Converts a JavaScript value to a JavaScript Object Notation (JSON) string. @@ -274,7 +274,7 @@ interface JSON { stringify( value: A, replacer?: (string | number)[] | null | undefined, - space?: string | number | null | undefined + space?: string | number | null | undefined, ): StringifyResult>; /** * Converts a JavaScript value to a JavaScript Object Notation (JSON) string. @@ -287,9 +287,9 @@ interface JSON { replacer: ( this: JSONComposite, key: string, - value: ToJSON + value: ToJSON, ) => JSONValueF, - space?: string | number | null | undefined + space?: string | number | null | undefined, ): string; /** * Converts a JavaScript value to a JavaScript Object Notation (JSON) string. @@ -302,9 +302,9 @@ interface JSON { replacer: ( this: JSONComposite, key: string, - value: ToJSON + value: ToJSON, ) => JSONValueF | undefined, - space?: string | number | null | undefined + space?: string | number | null | undefined, ): string | undefined; } @@ -319,7 +319,7 @@ interface ReadonlyArray { */ every( predicate: (this: This, value: T, index: number, array: this) => value is S, - thisArg?: This + thisArg?: This, ): this is { [K in keyof this]: S }; /** * Determines whether all the members of an array satisfy the specified test. @@ -331,7 +331,7 @@ interface ReadonlyArray { */ every( predicate: (this: This, value: T, index: number, array: this) => boolean, - thisArg?: This + thisArg?: This, ): boolean; /** * Determines whether the specified callback function returns true for any element of an array. @@ -343,7 +343,7 @@ interface ReadonlyArray { */ some( predicate: (this: This, value: T, index: number, array: this) => boolean, - thisArg?: This + thisArg?: This, ): boolean; /** * Performs the specified action for each element in an array. @@ -352,7 +352,7 @@ interface ReadonlyArray { */ forEach( callbackfn: (this: This, value: T, index: number, array: this) => void, - thisArg?: This + thisArg?: This, ): void; /** * Calls a defined callback function on each element of an array, and returns an array that contains the results. @@ -361,7 +361,7 @@ interface ReadonlyArray { */ map( callbackfn: (this: This, value: T, index: number, array: this) => U, - thisArg?: This + thisArg?: This, ): Cast<{ -readonly [K in keyof this]: U }, U[]>; /** * Returns the elements of an array that meet the condition specified in a callback function. @@ -370,7 +370,7 @@ interface ReadonlyArray { */ filter( predicate: (this: This, value: T, index: number, array: this) => value is S, - thisArg?: This + thisArg?: This, ): S[]; /** * Returns the elements of an array that meet the condition specified in a callback function. @@ -379,7 +379,7 @@ interface ReadonlyArray { */ filter( predicate: (this: This, value: T, index: number, array: this) => boolean, - thisArg?: This + thisArg?: This, ): T[]; /** * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. @@ -390,8 +390,8 @@ interface ReadonlyArray { previousValue: T | U, currentValue: T, currentIndex: number, - array: this - ) => U + array: this, + ) => U, ): T | U; /** * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. @@ -403,9 +403,9 @@ interface ReadonlyArray { previousValue: U, currentValue: T, currentIndex: number, - array: this + array: this, ) => U, - initialValue: U + initialValue: U, ): U; /** * Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. @@ -416,8 +416,8 @@ interface ReadonlyArray { previousValue: T | U, currentValue: T, currentIndex: number, - array: this - ) => U + array: this, + ) => U, ): T | U; /** * Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. @@ -429,9 +429,9 @@ interface ReadonlyArray { previousValue: U, currentValue: T, currentIndex: number, - array: this + array: this, ) => U, - initialValue: U + initialValue: U, ): U; } @@ -446,7 +446,7 @@ interface Array { */ every( predicate: (this: This, value: T, index: number, array: this) => value is S, - thisArg?: This + thisArg?: This, ): this is { [K in keyof this]: S }; /** * Determines whether all the members of an array satisfy the specified test. @@ -458,7 +458,7 @@ interface Array { */ every( predicate: (this: This, value: T, index: number, array: this) => boolean, - thisArg?: This + thisArg?: This, ): boolean; /** * Determines whether the specified callback function returns true for any element of an array. @@ -470,7 +470,7 @@ interface Array { */ some( predicate: (this: This, value: T, index: number, array: this) => boolean, - thisArg?: This + thisArg?: This, ): boolean; /** * Performs the specified action for each element in an array. @@ -479,7 +479,7 @@ interface Array { */ forEach( callbackfn: (this: This, value: T, index: number, array: this) => void, - thisArg?: This + thisArg?: This, ): void; /** * Calls a defined callback function on each element of an array, and returns an array that contains the results. @@ -488,7 +488,7 @@ interface Array { */ map( callbackfn: (this: This, value: T, index: number, array: this) => U, - thisArg?: This + thisArg?: This, ): Cast<{ [K in keyof this]: U }, U[]>; /** * Returns the elements of an array that meet the condition specified in a callback function. @@ -497,7 +497,7 @@ interface Array { */ filter( predicate: (this: This, value: T, index: number, array: this) => value is S, - thisArg?: This + thisArg?: This, ): S[]; /** * Returns the elements of an array that meet the condition specified in a callback function. @@ -506,7 +506,7 @@ interface Array { */ filter( predicate: (this: This, value: T, index: number, array: this) => boolean, - thisArg?: This + thisArg?: This, ): T[]; /** * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. @@ -517,8 +517,8 @@ interface Array { previousValue: T | U, currentValue: T, currentIndex: number, - array: this - ) => U + array: this, + ) => U, ): T | U; /** * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. @@ -530,9 +530,9 @@ interface Array { previousValue: U, currentValue: T, currentIndex: number, - array: this + array: this, ) => U, - initialValue: U + initialValue: U, ): U; /** * Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. @@ -543,8 +543,8 @@ interface Array { previousValue: T | U, currentValue: T, currentIndex: number, - array: this - ) => U + array: this, + ) => U, ): T | U; /** * Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. @@ -556,9 +556,9 @@ interface Array { previousValue: U, currentValue: T, currentIndex: number, - array: this + array: this, ) => U, - initialValue: U + initialValue: U, ): U; } @@ -576,8 +576,8 @@ declare type PromiseConstructorLike = new ( resolve: undefined extends T ? (value?: T | PromiseLike) => void : (value: T | PromiseLike) => void, - reject: (reason?: any) => void - ) => void + reject: (reason?: any) => void, + ) => void, ) => PromiseLike; interface PromiseLike { @@ -589,7 +589,7 @@ interface PromiseLike { */ then( onfulfilled?: null | undefined, - onrejected?: ((reason: unknown) => T | PromiseLike) | null | undefined + onrejected?: ((reason: unknown) => T | PromiseLike) | null | undefined, ): PromiseLike; /** @@ -600,7 +600,7 @@ interface PromiseLike { */ then( onfulfilled: (value: T) => U | PromiseLike, - onrejected?: ((reason: unknown) => U | PromiseLike) | null | undefined + onrejected?: ((reason: unknown) => U | PromiseLike) | null | undefined, ): PromiseLike; } @@ -613,7 +613,7 @@ interface Promise extends PromiseLike { */ then( onfulfilled?: null | undefined, - onrejected?: ((reason: unknown) => T | PromiseLike) | null | undefined + onrejected?: ((reason: unknown) => T | PromiseLike) | null | undefined, ): Promise; /** @@ -624,7 +624,7 @@ interface Promise extends PromiseLike { */ then( onfulfilled: (value: T) => U | PromiseLike, - onrejected?: ((reason: unknown) => U | PromiseLike) | null | undefined + onrejected?: ((reason: unknown) => U | PromiseLike) | null | undefined, ): Promise; /** @@ -633,7 +633,7 @@ interface Promise extends PromiseLike { * @returns A Promise for the completion of the callback. */ catch( - onrejected?: ((reason: unknown) => T | PromiseLike) | null | undefined + onrejected?: ((reason: unknown) => T | PromiseLike) | null | undefined, ): Promise; } @@ -651,9 +651,9 @@ interface TypedNumberArray { this: This, value: number, index: number, - array: this + array: this, ) => boolean, - thisArg?: This + thisArg?: This, ): boolean; /** * Returns the elements of an array that meet the condition specified in a callback function. @@ -667,9 +667,9 @@ interface TypedNumberArray { this: This, value: number, index: number, - array: this + array: this, ) => boolean, - thisArg?: This + thisArg?: This, ): TypedNumberArray; /** * Returns the value of the first element in the array where predicate is true, and undefined @@ -682,7 +682,7 @@ interface TypedNumberArray { */ find( predicate: (this: This, value: number, index: number, obj: this) => boolean, - thisArg?: This + thisArg?: This, ): number | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -695,7 +695,7 @@ interface TypedNumberArray { */ findIndex( predicate: (this: This, value: number, index: number, obj: this) => boolean, - thisArg?: This + thisArg?: This, ): number; /** * Performs the specified action for each element in an array. @@ -706,7 +706,7 @@ interface TypedNumberArray { */ forEach( callbackfn: (this: This, value: number, index: number, array: this) => void, - thisArg?: This + thisArg?: This, ): void; /** * Calls a defined callback function on each element of an array, and returns an array that @@ -721,9 +721,9 @@ interface TypedNumberArray { this: This, value: number, index: number, - array: this + array: this, ) => number, - thisArg?: This + thisArg?: This, ): TypedNumberArray; /** * Calls the specified callback function for all the elements in an array. The return value of @@ -737,8 +737,8 @@ interface TypedNumberArray { previousValue: number | U, currentValue: number, currentIndex: number, - array: this - ) => U + array: this, + ) => U, ): number | U; /** * Calls the specified callback function for all the elements in an array. The return value of @@ -755,9 +755,9 @@ interface TypedNumberArray { previousValue: U, currentValue: number, currentIndex: number, - array: this + array: this, ) => U, - initialValue: U + initialValue: U, ): U; /** * Calls the specified callback function for all the elements in an array, in descending order. @@ -771,8 +771,8 @@ interface TypedNumberArray { previousValue: number | U, currentValue: number, currentIndex: number, - array: this - ) => U + array: this, + ) => U, ): number | U; /** * Calls the specified callback function for all the elements in an array, in descending order. @@ -789,9 +789,9 @@ interface TypedNumberArray { previousValue: U, currentValue: number, currentIndex: number, - array: this + array: this, ) => U, - initialValue: U + initialValue: U, ): U; /** * Determines whether the specified callback function returns true for any element of an array. @@ -806,9 +806,9 @@ interface TypedNumberArray { this: This, value: number, index: number, - array: this + array: this, ) => boolean, - thisArg?: This + thisArg?: This, ): boolean; } @@ -827,6 +827,6 @@ interface TypedNumberArrayConstructor { from( arrayLike: ArrayLike, mapfn: (this: This, v: T, k: number) => number, - thisArg?: This + thisArg?: This, ): TypedNumberArray; } diff --git a/tests/src/es2015.collection.ts b/tests/src/es2015.collection.ts index 2d9a14b..23d5e72 100644 --- a/tests/src/es2015.collection.ts +++ b/tests/src/es2015.collection.ts @@ -18,7 +18,7 @@ import { expectType } from "tsd"; function () { expectType(this.foo); }, - { foo: "foo" } + { foo: "foo" }, ); const map2 = new Map(); @@ -59,6 +59,6 @@ import { expectType } from "tsd"; function () { expectType(this.foo); }, - { foo: "foo" } + { foo: "foo" }, ); } diff --git a/tests/src/es2015.core.ts b/tests/src/es2015.core.ts index 48604b0..a220a4a 100644 --- a/tests/src/es2015.core.ts +++ b/tests/src/es2015.core.ts @@ -27,7 +27,7 @@ import { expectError, expectType } from "tsd"; expectType<{ foo: number } & { bar: string } & { baz: boolean }>(obj3); const obj4 = Object.assign( { foo: 123 } as { foo: number } | { bar: string }, - { baz: true } + { baz: true }, ); expectType<({ foo: number } | { bar: string }) & { baz: boolean }>(obj4); expectType(Object.getOwnPropertySymbols([])); diff --git a/tests/src/es2015.proxy.ts b/tests/src/es2015.proxy.ts index 02212c3..2ba761b 100644 --- a/tests/src/es2015.proxy.ts +++ b/tests/src/es2015.proxy.ts @@ -25,5 +25,5 @@ new Proxy( expectType(newTarget); return {}; }, - } + }, ); diff --git a/tests/src/es2015.reflect.ts b/tests/src/es2015.reflect.ts index 4826b5d..a85d602 100644 --- a/tests/src/es2015.reflect.ts +++ b/tests/src/es2015.reflect.ts @@ -1,6 +1,6 @@ import { expectType } from "tsd"; -class A{} +class A {} expectType(Reflect.apply(() => {}, {}, [])); // @ts-expect-error diff --git a/tests/src/es2017.object.ts b/tests/src/es2017.object.ts index 6e24974..b7753b9 100644 --- a/tests/src/es2017.object.ts +++ b/tests/src/es2017.object.ts @@ -2,7 +2,7 @@ import { expectError, expectType } from "tsd"; function createGenericRecord( keys: K[], - values: V[] + values: V[], ): Record { return Object.fromEntries(keys.map((k, i) => [k, values[i]!] as const)); } diff --git a/tests/src/es2020.promise.ts b/tests/src/es2020.promise.ts index 25ce51f..099c24e 100644 --- a/tests/src/es2020.promise.ts +++ b/tests/src/es2020.promise.ts @@ -1,7 +1,7 @@ import { expectType } from "tsd"; const test = async ( - values: Iterable>> + values: Iterable>>, ) => { const results = await Promise.allSettled(values); diff --git a/tests/src/es2021.promise.ts b/tests/src/es2021.promise.ts index 683ec13..1073bdf 100644 --- a/tests/src/es2021.promise.ts +++ b/tests/src/es2021.promise.ts @@ -1,7 +1,7 @@ import { expectType } from "tsd"; const test = async ( - values: Iterable>> + values: Iterable>>, ) => { const result = await Promise.any(values); expectType(result); diff --git a/tests/src/es2022.object.ts b/tests/src/es2022.object.ts index 5f2e951..dc5b8e3 100644 --- a/tests/src/es2022.object.ts +++ b/tests/src/es2022.object.ts @@ -34,14 +34,14 @@ import { expectError, expectType } from "tsd"; // https://github.com/uhyo/better-typescript-lib/issues/13 { - const protoObj = { protoProp: 'protoProp' }; + const protoObj = { protoProp: "protoProp" }; const obj: Record = Object.create(protoObj); - obj.ownProp = 'ownProp'; + obj.ownProp = "ownProp"; for (const key in obj) { if (!Object.hasOwn(obj, key)) continue; expectType>(obj); obj[key]; } -} \ No newline at end of file +} diff --git a/tests/src/es5.ts b/tests/src/es5.ts index a6dcffc..cf34e39 100644 --- a/tests/src/es5.ts +++ b/tests/src/es5.ts @@ -56,26 +56,26 @@ const testPromise = (promise: Promise) => { expectType>(promise.then((str) => str.length, null)); expectType>(promise.then((str) => str.length, undefined)); expectType>( - promise.then((str) => Promise.resolve(str.length)) + promise.then((str) => Promise.resolve(str.length)), ); expectType>( promise.then( (str) => str.length, - (err) => `${err}`.length - ) + (err) => `${err}`.length, + ), ); expectType>( promise.then( (str) => str.length, - (err) => Promise.resolve(`${err}`.length) - ) + (err) => Promise.resolve(`${err}`.length), + ), ); // @ts-expect-error promise.then((str: string) => str); promise.then( (str: string) => str.length, // @ts-expect-error - () => "NaN" + () => "NaN", ); // @ts-expect-error promise.then(null, (err) => `${err}`.length); @@ -94,7 +94,7 @@ expectType(Object.getPrototypeOf([])); expectError(Object.getPrototypeOf(null)); // Object.getOwnPropertyDescriptor expectType( - Object.getOwnPropertyDescriptor([], "foo") + Object.getOwnPropertyDescriptor([], "foo"), ); expectError(Object.getOwnPropertyDescriptor(null, "foo")); // Object.getOwnPropertyNames @@ -117,7 +117,7 @@ const obj = { const obj1 = { baz: true }; expectType<{ foo: number; bar: string }>(Object.create(null, obj)); expectType<{ foo: number; bar: string; baz: boolean }>( - Object.create(obj1, obj) + Object.create(obj1, obj), ); // Object @@ -172,12 +172,12 @@ expectType<{ foo: number; bar: string; baz: boolean }>( expectType<{ foo: number }>( Object.defineProperty({}, "foo", { value: 123, - }) + }), ); expectType<{ foo: number } | { bar: number }>( Object.defineProperty({}, "foo" as "foo" | "bar", { value: 123, - }) + }), ); expectType<{ foo: number; bar: string; baz: boolean }>( @@ -192,8 +192,8 @@ expectType<{ foo: number; bar: string; baz: boolean }>( return true; }, }, - } - ) + }, + ), ); } @@ -218,7 +218,10 @@ expectType<{ foo: number; bar: string; baz: boolean }>( // NewableFunction { class Foo { - constructor(private a: number, private b: number) {} + constructor( + private a: number, + private b: number, + ) {} } expectType(Foo.bind(null)); expectType Foo>(Foo.bind(null, 123)); @@ -247,39 +250,39 @@ expectType<{ foo: number; bar: string; baz: boolean }>( expectType(JSON.parse("{}")); expectType( JSON.parse('{"p": 5}', (key, value) => - typeof value === "number" ? value * 2 : value - ) + typeof value === "number" ? value * 2 : value, + ), ); expectType( JSON.parse('{"p": 5}', (key, value) => - typeof value === "number" ? value * 2 : value - ) + typeof value === "number" ? value * 2 : value, + ), ); expectError( JSON.parse('[[1,"one"],[2,"two"],[3,"three"]]', (key, value) => - key === "" ? new Map(value) : value - ) + key === "" ? new Map(value) : value, + ), ); expectType( JSON.parse('[[1,"one"],[2,"two"],[3,"three"]]', (key, value) => - key === "" && isNumberStringEntries(value) ? new Map(value) : value - ) + key === "" && isNumberStringEntries(value) ? new Map(value) : value, + ), ); type JSONValueWithMap1 = JSONValue | Map; expectError( JSON.parse( '[[1,"one"],[2,"two"],[3,"three"]]', (key, value) => - key === "" && isNumberStringEntries(value) ? new Map(value) : value - ) + key === "" && isNumberStringEntries(value) ? new Map(value) : value, + ), ); type JSONValueWithMap2 = JSONValueF>; expectError( JSON.parse( '[[1,"one"],[2,"two"],[3,"three"]]', (key, value) => - key === "" && isNumberStringEntries(value) ? new Map(value) : value - ) + key === "" && isNumberStringEntries(value) ? new Map(value) : value, + ), ); type JSONValueWithMap3 = | JSONPrimitive @@ -290,8 +293,8 @@ expectType<{ foo: number; bar: string; baz: boolean }>( JSON.parse( '[[1,"one"],[2,"two"],[3,"three"]]', (key, value) => - key === "" && isNumberStringEntries(value) ? new Map(value) : value - ) + key === "" && isNumberStringEntries(value) ? new Map(value) : value, + ), ); // JSON.stringify @@ -340,24 +343,24 @@ expectType<{ foo: number; bar: string; baz: boolean }>( // JSON.stringify with replacer function const importantDates = new Map(); expectError( - JSON.stringify(importantDates, (key, value) => Object.fromEntries(value)) + JSON.stringify(importantDates, (key, value) => Object.fromEntries(value)), ); expectError( JSON.stringify>(importantDates, (key, value) => - Object.fromEntries(value) - ) + Object.fromEntries(value), + ), ); type Value = Date | Map; expectType( JSON.stringify(importantDates, (key, value) => - typeof value === "string" ? value : Object.fromEntries(value) - ) + typeof value === "string" ? value : Object.fromEntries(value), + ), ); expectType( JSON.stringify(importantDates, (key, value) => { if (typeof value !== "string") return Object.fromEntries(value); return new Date(value) < new Date("1900-01-01") ? undefined : value; - }) + }), ); } @@ -374,15 +377,15 @@ expectType<{ foo: number; bar: string; baz: boolean }>( a1.reduce((x) => { expectType(x); return "foo"; - }) + }), ); expectType( a1.reduce((x) => { expectType(x); return "foo"; - }, "foo") + }, "foo"), ); - expectType(a1.reduceRight); + expectType<(typeof a1)["reduce"]>(a1.reduceRight); expectError(a1.filter((x) => x)); expectError(a1.every((x) => x)); @@ -413,15 +416,15 @@ expectType<{ foo: number; bar: string; baz: boolean }>( a1.reduce((x) => { expectType(x); return "foo"; - }) + }), ); expectType( a1.reduce((x) => { expectType(x); return "foo"; - }, "foo") + }, "foo"), ); - expectType(a1.reduceRight); + expectType<(typeof a1)["reduce"]>(a1.reduceRight); expectError(a1.filter((x) => x)); expectError(a1.every((x) => x)); @@ -466,7 +469,7 @@ expectType<{ foo: number; bar: string; baz: boolean }>( const mapped: string[] = arr.map((v) => magic((value) => { expectType(value); - }) + }), ); } }