Skip to content

Commit

Permalink
Merge branch 'DefinitelyTyped:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
mohitpubnub committed Jan 11, 2024
2 parents 06e64c8 + b0a62b6 commit 4426b61
Show file tree
Hide file tree
Showing 83 changed files with 2,771 additions and 315 deletions.
2 changes: 1 addition & 1 deletion types/bun/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"https://bun.sh"
],
"dependencies": {
"bun-types": "1.0.18"
"bun-types": "1.0.21"
},
"devDependencies": {
"@types/bun": "workspace:."
Expand Down
13 changes: 13 additions & 0 deletions types/clownface/clownface-tests.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import DataFactory from "@rdfjs/data-model/Factory.js";
import DatasetFactory from "@rdfjs/dataset/Factory.js";
import Environment from "@rdfjs/environment/Environment.js";
import { BlankNode, Dataset, DatasetCore, Literal, NamedNode, Quad_Graph, Term, Variable } from "@rdfjs/types";
Expand Down Expand Up @@ -196,6 +197,18 @@ function testFactory() {

const namedNodeContext: AnyPointer<NamedNode, Dataset> = <any> {};
const deriveContextFromOtherNamedNodeContext: AnyPointer<NamedNode, Dataset> = clownface(namedNodeContext);

const factory = new Environment([
DatasetFactory,
DataFactory,
]);
const withFactory = clownface({ dataset, factory });

const incompatibleFactory = new Environment([
DataFactory,
]);
// @ts-expect-error
const withIncompatibleFactory = clownface({ dataset, factory: incompatibleFactory });
}

function testFilter() {
Expand Down
17 changes: 15 additions & 2 deletions types/clownface/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
import { BlankNode, DatasetCore, DatasetCoreFactory, Literal, NamedNode, Quad_Graph, Term } from "@rdfjs/types";
import { Environment } from "@rdfjs/environment/Environment.js";
import {
BlankNode,
DataFactory,
DatasetCore,
DatasetCoreFactory,
Literal,
NamedNode,
Quad_Graph,
Term,
} from "@rdfjs/types";
import Context from "./lib/Context.js";

export type AnyContext = Term | Term[] | undefined;
Expand All @@ -20,7 +30,10 @@ interface NodeOptions {
}

export type ClownfaceInit<D extends DatasetCore = DatasetCore> = Partial<
Pick<AnyPointer<AnyContext, D>, "dataset" | "_context"> & { graph: Quad_Graph }
Pick<AnyPointer<AnyContext, D>, "dataset" | "_context"> & {
graph: Quad_Graph;
factory: Environment<DatasetCoreFactory | DataFactory>;
}
>;

type Iteratee<T extends AnyContext = undefined, D extends DatasetCore = DatasetCore> = T extends undefined ? never
Expand Down
5 changes: 3 additions & 2 deletions types/clownface/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@
],
"type": "module",
"dependencies": {
"@rdfjs/types": ">=1.0.0"
"@rdfjs/types": ">=1.0.0",
"@types/rdfjs__environment": "*"
},
"devDependencies": {
"@types/clownface": "workspace:.",
"@types/rdfjs__dataset": "*",
"@types/rdfjs__environment": "*"
"@types/rdfjs__data-model": "*"
},
"owners": [
{
Expand Down
5 changes: 5 additions & 0 deletions types/drawflow/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,11 @@ export default class Drawflow {
* @param callback (event: id of Node)
*/
on(eventName: "nodeRemoved", callback: (event: number) => void): void;
/**
* @param eventName
* @param callback (event: id of Node df-* attributes changed.)
*/
on(eventName: "nodeDataChanged", callback: (event: number) => void): void;
/**
* @param eventName
* @param callback (event: id of Node)
Expand Down
6 changes: 6 additions & 0 deletions types/eslint/eslint-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,12 @@ rule = {

context.getScope();

if (typeof context.parserPath === "string") {
context.parserPath;
} else {
context.languageOptions?.parser;
}

context.markVariableAsUsed("foo");

context.report({ message: "foo", node: AST });
Expand Down
3 changes: 2 additions & 1 deletion types/eslint/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -753,7 +753,8 @@ export namespace Rule {
id: string;
options: any[];
settings: { [name: string]: any };
parserPath: string;
parserPath: string | undefined;
languageOptions: Linter.FlatConfig["languageOptions"];
parserOptions: Linter.ParserOptions;
parserServices: SourceCode.ParserServices;
cwd: string;
Expand Down
32 changes: 32 additions & 0 deletions types/facebook-instant-games/facebook-instant-games-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -304,3 +304,35 @@ FBInstant.squads.canUseSquadsAsync().then(isEligible => {
});
}
});

const allErrorCodes: FBInstant.ErrorCodeType[] = [
"ADS_FREQUENT_LOAD",
"ADS_NOT_LOADED",
"ADS_NO_FILL",
"ADS_TOO_MANY_INSTANCES",
"ARENAS_NOT_FOUND",
"ANALYTICS_POST_EXCEPTION",
"CAMERA_EFFECT_NOT_FOUND",
"CLIENT_REQUIRES_UPDATE",
"CLIENT_UNSUPPORTED_OPERATION",
"DUPLICATE_POST",
"GAMING_SQUAD_NOT_FOUND",
"GROUP_NOT_LINKED",
"INVALID_OPERATION",
"INVALID_PARAM",
"LEADERBOARD_NOT_FOUND",
"LEADERBOARD_WRONG_CONTEXT",
"LIVE_MATCH_NOT_FOUND",
"LIVE_STREAMS_NOT_FOUND",
"NETWORK_FAILURE",
"PAGE_NOT_LINKED",
"PAYMENTS_NOT_INITIALIZED",
"PAYMENTS_OPERATION_FAILURE",
"PENDING_REQUEST",
"RATE_LIMITED",
"SAME_CONTEXT",
"TOURNAMENT_NOT_FOUND",
"UNKNOWN",
"USER_INPUT",
"VIDEO_NOT_FOUND",
];
19 changes: 17 additions & 2 deletions types/facebook-instant-games/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -790,6 +790,7 @@ declare namespace FBInstant {
* @throws INVALID_PARAM
* @throws NETWORK_FAILURE
* @throws CLIENT_UNSUPPORTED_OPERATION
* @deprecated Stats APIs (getStatsAsync(), setStatsAsync() and incrementStatsAsync()) have been fully removed on September 28th, 2022.
*/
getStatsAsync(keys?: string[]): Promise<StatsObject>;

Expand All @@ -804,6 +805,7 @@ declare namespace FBInstant {
* @throws NETWORK_FAILURE
* @throws PENDING_REQUEST
* @throws CLIENT_UNSUPPORTED_OPERATION
* @deprecated Stats APIs (getStatsAsync(), setStatsAsync() and incrementStatsAsync()) have been fully removed on September 28th, 2022.
*/
setStatsAsync(stats: StatsObject): Promise<void>;

Expand All @@ -819,6 +821,7 @@ declare namespace FBInstant {
* @throws NETWORK_FAILURE
* @throws PENDING_REQUEST
* @throws CLIENT_UNSUPPORTED_OPERATION
* @deprecated Stats APIs (getStatsAsync(), setStatsAsync() and incrementStatsAsync()) have been fully removed on September 28th, 2022.
*/
incrementStatsAsync(increments: IncrementObject): Promise<StatsObject>;

Expand Down Expand Up @@ -2133,22 +2136,34 @@ declare namespace FBInstant {

type ErrorCodeType =
| "ADS_FREQUENT_LOAD"
| "ADS_NO_FILL"
| "ADS_NOT_LOADED"
| "ADS_NO_FILL"
| "ADS_TOO_MANY_INSTANCES"
| "ARENAS_NOT_FOUND"
| "ANALYTICS_POST_EXCEPTION"
| "CAMERA_EFFECT_NOT_FOUND"
| "CLIENT_REQUIRES_UPDATE"
| "CLIENT_UNSUPPORTED_OPERATION"
| "DUPLICATE_POST"
| "GAMING_SQUAD_NOT_FOUND"
| "GROUP_NOT_LINKED"
| "INVALID_OPERATION"
| "INVALID_PARAM"
| "LEADERBOARD_NOT_FOUND"
| "LEADERBOARD_WRONG_CONTEXT"
| "LIVE_MATCH_NOT_FOUND"
| "LIVE_STREAMS_NOT_FOUND"
| "NETWORK_FAILURE"
| "PAGE_NOT_LINKED"
| "PAYMENTS_NOT_INITIALIZED"
| "PAYMENTS_OPERATION_FAILURE"
| "PENDING_REQUEST"
| "RATE_LIMITED"
| "SAME_CONTEXT"
| "TOURNAMENT_NOT_FOUND"
| "UNKNOWN"
| "USER_INPUT";
| "USER_INPUT"
| "VIDEO_NOT_FOUND";

/**
* A function that will get called when user requested to capture a screenshot.
Expand Down
2 changes: 2 additions & 0 deletions types/json-diff/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,5 @@ export interface DiffStringOptions extends DiffOptions {

export function diff(obj1: unknown, obj2: unknown, options?: DiffOptions): any;
export function diffString(obj1: unknown, obj2: unknown, options?: DiffStringOptions): string;

export { colorize, colorizeToCallback } from "./lib/colorize";
24 changes: 23 additions & 1 deletion types/json-diff/json-diff-tests.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { diff, DiffOptions, diffString } from "json-diff";
import { colorize, colorizeToCallback, diff, DiffOptions, diffString } from "json-diff";

const options: DiffOptions = {
verbose: true,
Expand All @@ -24,3 +24,25 @@ diffString({}, { Hello: "World" }, {
...options,
color: true,
});

colorize(diff({}, { Hello: "World" }));

colorizeToCallback(diff({}, { Hello: "World" }), {}, (color, line) => {
switch (color) {
case " ":
// do something

break;
case "-":
// do something

break;
case "+":
// do something

break;

default:
break;
}
});
18 changes: 18 additions & 0 deletions types/json-diff/lib/colorize.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
export type DiffObject = object | string;

export interface ColorizeOptions {
theme?: Theme;
color?: boolean;
}

export type Theme = Record<ThemeType, ThemeFunction>;
export type ThemeType = " " | "+" | "-";
export type ThemeFunction = (str: string) => string;

export interface OutputCallback {
(color: ThemeType, line: string): void;
}

export function colorizeToCallback(diff: DiffObject, options: ColorizeOptions, output: OutputCallback): void;
export function colorize(diff: DiffObject, options?: ColorizeOptions): string;
export function colorizeToArray(diff: DiffObject, options: ColorizeOptions): string[];
9 changes: 9 additions & 0 deletions types/koa/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
=============================================== */
/// <reference types="node" />
import * as accepts from "accepts";
import { AsyncLocalStorage } from "async_hooks";
import * as Cookies from "cookies";
import { EventEmitter } from "events";
import { IncomingHttpHeaders, IncomingMessage, OutgoingHttpHeaders, Server, ServerResponse } from "http";
Expand Down Expand Up @@ -443,6 +444,7 @@ declare class Application<
response: Application.BaseResponse;
silent: boolean;
keys: Keygrip | string[];
ctxStorage: AsyncLocalStorage<Application.Context> | undefined;

/**
* @param {object} [options] Application options
Expand All @@ -452,6 +454,7 @@ declare class Application<
* @param {number} [options.subdomainOffset] Subdomain offset
* @param {string} [options.proxyIpHeader] Proxy IP header, defaults to X-Forwarded-For
* @param {number} [options.maxIpsCount] Max IPs read from proxy IP header, default to 0 (means infinity)
* @param {boolean} [options.asyncLocalStorage] Enable AsyncLocalStorage
*/
constructor(options?: {
env?: string | undefined;
Expand All @@ -460,6 +463,7 @@ declare class Application<
subdomainOffset?: number | undefined;
proxyIpHeader?: string | undefined;
maxIpsCount?: number | undefined;
asyncLocalStorage?: boolean | undefined;
});

/**
Expand Down Expand Up @@ -520,6 +524,11 @@ declare class Application<
* @api private
*/
onerror(err: Error): void;

/**
* return currnect contenxt from async local storage
*/
readonly currentContext: Application.Context | undefined;
}

declare namespace Application {
Expand Down
2 changes: 1 addition & 1 deletion types/koa/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"name": "@types/koa",
"version": "2.13.9999",
"version": "2.14.9999",
"projects": [
"http://koajs.com"
],
Expand Down
1 change: 1 addition & 0 deletions types/koa/test/constructor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const app = new Koa({
subdomainOffset: 2,
proxyIpHeader: "XYZ-Forwarded-For",
maxIpsCount: 2,
asyncLocalStorage: true,
});

app.use(ctx => {
Expand Down
2 changes: 2 additions & 0 deletions types/koa/test/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,6 @@ app.use(ctx => {

app.listen(3000);

app.currentContext;

const server = app.listen();
2 changes: 1 addition & 1 deletion types/node/buffer.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ declare module "buffer" {
*
* The `Buffer` module pre-allocates an internal `Buffer` instance of
* size `Buffer.poolSize` that is used as a pool for the fast allocation of new`Buffer` instances created using `Buffer.allocUnsafe()`, `Buffer.from(array)`,
* and `Buffer.concat()` only when `size` is less than or equal to`Buffer.poolSize >> 1` (floor of `Buffer.poolSize` divided by two).
* and `Buffer.concat()` only when `size` is less than`Buffer.poolSize >>> 1` (floor of `Buffer.poolSize` divided by two).
*
* Use of this pre-allocated internal memory pool is a key difference between
* calling `Buffer.alloc(size, fill)` vs. `Buffer.allocUnsafe(size).fill(fill)`.
Expand Down
7 changes: 4 additions & 3 deletions types/node/crypto.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -638,9 +638,10 @@ declare module "crypto" {
export(options?: KeyExportOptions<"der">): Buffer;
export(options?: JwkKeyExportOptions): JsonWebKey;
/**
* Returns `true` or `false` depending on whether the keys have exactly the same type, value, and parameters.
* This method is not [constant time](https://en.wikipedia.org/wiki/Timing_attack).
* @since v16.15.0
* Returns `true` or `false` depending on whether the keys have exactly the same
* type, value, and parameters. This method is not [constant time](https://en.wikipedia.org/wiki/Timing_attack).
* @since v17.7.0, v16.15.0
* @param otherKeyObject A `KeyObject` with which to compare `keyObject`.
*/
equals(otherKeyObject: KeyObject): boolean;
/**
Expand Down
8 changes: 4 additions & 4 deletions types/node/dgram.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,13 +228,13 @@ declare module "dgram" {
*/
getSendBufferSize(): number;
/**
* @since v18.8.0,v16.19.0
* @return the number of bytes queued for sending.
* @since v18.8.0, v16.19.0
* @return Number of bytes queued for sending.
*/
getSendQueueSize(): number;
/**
* @since v18.8.0,v16.19.0
* @return the number of send requests currently in the queue awaiting to be processed.
* @since v18.8.0, v16.19.0
* @return Number of send requests currently in the queue awaiting to be processed.
*/
getSendQueueCount(): number;
/**
Expand Down
Loading

0 comments on commit 4426b61

Please sign in to comment.