Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions types/depd/depd-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,5 @@ process.on("deprecation", error => {
err.namespace; // $ExpectType string
err.stack; // $ExpectType string
});

process.listeners("deprecation"); // $ExpectType ((deprecationError: DeprecationError) => void)[]
2 changes: 1 addition & 1 deletion types/depd/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ declare global {
event: "deprecation",
listener: (deprecationError: depd.DeprecationError) => void,
): this;
listeners(event: "deprecation"): depd.DeprecationError[];
listeners(event: "deprecation"): Array<(deprecationError: depd.DeprecationError) => void>;
}
}
}
5 changes: 5 additions & 0 deletions types/get-form-data/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
*
!**/*.d.ts
!**/*.d.cts
!**/*.d.mts
!**/*.d.*.ts
24 changes: 24 additions & 0 deletions types/get-form-data/get-form-data-tests.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import getFormData, { getFieldData } from "get-form-data";

declare const form: HTMLFormElement;

// $ExpectType Record<string, Value>
let data = getFormData(form);

data.boolean = true;
data.string = "string";
data.stringArray = ["string"];
data.file = new File([], "");
data.files = [new File([], "")];

getFormData(form, {});
getFormData(form, { includeDisabled: true });
getFormData(form, { trim: true });

// $ExpectType Value | null
let value = getFieldData(form, "name");
value = getFormData.getFieldData(form, "other");

getFieldData(form, "a", {});
getFieldData(form, "b", { includeDisabled: true });
getFieldData(form, "c", { trim: true });
63 changes: 63 additions & 0 deletions types/get-form-data/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
export interface Options {
/**
* if `true`, disabled inputs will not be ignored.
*
* @default false
*/
includeDisabled?: boolean | undefined;

/**
* if `true`, leading and trailing whitespace will be trimmed from user input in text entry form
* inputs.
*
* @default false
*/
trim?: boolean | undefined;
}

export type Value = boolean | string | string[] | File | File[];

/**
* Extracts data from a `<form>`'s `.elements` collection - in order to use `.elements`, form inputs
* must have `name` or `id` attributes. Since multiple inputs can't have the same `id` and a `name`
* allows an input to qualify as a successful control for form submission, `name` attributes are
* preferred and will be given priority if both are present.
*
* @returns
* Properties in the returned data object are mostly consistent with what would have been sent as
* request parameters if the form had been submitted:
*
* * Disabled inputs are ignored by default.
* * Text inputs will always contribute a value, which will be `''` if they are empty.
* * Checkbox inputs will only contribute a value if they are checked, in which case their `value`
* attribute will be used.
* * Form elements which represent multiple values (select-multiple, or multiple inputs with the
* same name, file inputs with `multiple`) will only contribute a value if they have at least one
* value to submit. Their values will always be held in an `Array`, even if there is only one.
*
* Exceptions to this are:
*
* * If a checked checkbox doesn't have a `value` attribute, its value will be `true`. Normally it
* would default to `'on'` when submitted, but this isn't as useful a default on the client.
* * Buttons are completely ignored, as it's only possible to determine which button counts as
* successful after it's been used to submit the form.
*/
declare function getFormData(form: HTMLFormElement, options?: Options): Record<string, Value>;
declare namespace getFormData {
export { getFieldData };
}
export default getFormData;

/**
* Extracts data for a named field from a `<form>`'s `.elements` collection.
*
* Options are as documented for {@link getFormData}.
*
* @returns
* This function is used by {@link getFormData}, so the documentation for individual return values
* above also applies.
*
* `null` will be returned if the field is non-existent, disabled, or shouldn't contribute a value
* (e.g. unchecked checkboxes, multiple selects with no selections, file inputs with no selections).
*/
export function getFieldData(form: HTMLFormElement, fieldName: string, options?: Options): Value | null;
17 changes: 17 additions & 0 deletions types/get-form-data/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"private": true,
"name": "@types/get-form-data",
"version": "3.0.9999",
"projects": [
"https://github.com/insin/get-form-data"
],
"devDependencies": {
"@types/get-form-data": "workspace:."
},
"owners": [
{
"name": "Remco Haszing",
"githubUsername": "remcohaszing"
}
]
}
20 changes: 20 additions & 0 deletions types/get-form-data/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"compilerOptions": {
"module": "node16",
"lib": [
"dom",
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictFunctionTypes": true,
"strictNullChecks": true,
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"get-form-data-tests.ts"
]
}
2 changes: 1 addition & 1 deletion types/leaflet/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3023,7 +3023,7 @@ export namespace Icon {
export function icon(options: IconOptions): Icon;

export interface DivIconOptions extends BaseIconOptions {
html?: string | HTMLElement | false | undefined;
html?: string | Element | false | undefined;
bgPos?: PointExpression | undefined;
iconSize?: PointExpression | undefined;
iconAnchor?: PointExpression | undefined;
Expand Down
2 changes: 1 addition & 1 deletion types/leaflet/leaflet-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,7 @@ class MyDivIcon extends L.DivIcon {
}

const divIconHtmlAsString = L.divIcon({ html: "" });
const divIconHtmlAsElement = L.divIcon({ html: htmlElement });
const divIconHtmlAsElement = L.divIcon({ html: svgElement });
const divIconHtmlAsFalse = L.divIcon({ html: false });
let defaultIcon = new L.Icon.Default();
defaultIcon = new L.Icon.Default({ imagePath: "apath" });
Expand Down
2 changes: 2 additions & 0 deletions types/lodash/conforms.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import { conforms } from "./index";
export = conforms;
12 changes: 12 additions & 0 deletions types/lodash/lodash-tests.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
// eslint-disable-next-line @definitelytyped/no-relative-import-in-test
import fp = require("./fp");
import _ = require("lodash");
import conforms = require("lodash/conforms");
import stubArray = require("lodash/stubArray");
import stubObject = require("lodash/stubObject");
import stubString = require("lodash/stubString");

import type {
GetFieldType,
Expand Down Expand Up @@ -3964,6 +3968,7 @@ fp.now(); // $ExpectType number
_({ foo: (v: string) => false }).conforms().value()({ foo: "foo" }); // $ExpectType boolean
_.chain({ foo: (v: string) => false }).conforms().value()({ foo: "foo" }); // $ExpectType boolean
fp.conforms({ foo: (v: string) => false })({ foo: "foo" }); // $ExpectType boolean
conforms({ foo: (v: string) => false })({ foo: "foo" }); // $ExpectType boolean
}

// _.conformsTo
Expand Down Expand Up @@ -7835,3 +7840,10 @@ _.templateSettings; // $ExpectType TemplateSettings
type C = GetFieldType<Type, 'A'>; // $ExpectType 'ObjValA' | undefined
type D = GetFieldType<Type, 'length'>; // $ExpectType number | undefined
}

// Stub modules
{
stubArray(); // $ExpectType any[]
stubObject(); // $ExpectType any
stubString(); // $ExpectType string
}
2 changes: 2 additions & 0 deletions types/lodash/stubArray.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import { stubArray } from "./index";
export = stubArray;
2 changes: 2 additions & 0 deletions types/lodash/stubObject.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import { stubObject } from "./index";
export = stubObject;
2 changes: 2 additions & 0 deletions types/lodash/stubString.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import { stubString } from "./index";
export = stubString;
5 changes: 5 additions & 0 deletions types/mime-match/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
*
!**/*.d.ts
!**/*.d.cts
!**/*.d.mts
!**/*.d.*.ts
26 changes: 26 additions & 0 deletions types/mime-match/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/**
* A simple function to checker whether a target mime type matches a mime-type pattern (e.g. `image/jpeg` matches `image/jpeg` OR `image/*`).
*
* @example
* var match = require('mime-match');
*
* // exact match
* console.log(match('image/jpeg', 'image/jpeg'));
* // --> true
*
* // wildcard match
* console.log(match('image/jpeg', 'image/*'));
* // --> true
*
* // find which of our wildcard patterns matches a specific mimetype
* console.log(['application/*', 'image/*'].filter(match('image/jpeg')));
* // --> ['image/*']
*
* // charset suffix is ignored
* console.log(match('application/json', 'application/json; charset=utf-8'));
* // --> true
*/
declare function match(target: string): (pattern: string) => boolean;
declare function match(target: string, pattern: string): boolean;

export = match;
21 changes: 21 additions & 0 deletions types/mime-match/mime-match-tests.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import match = require("mime-match");

// exact match
// $ExpectType boolean
match("image/jpeg", "image/jpeg");
// --> true

// wildcard match
// $ExpectType boolean
match("image/jpeg", "image/*");
// --> true

// find which of our wildcard patterns matches a specific mimetype
// $ExpectType string[]
["application/*", "image/*"].filter(match("image/jpeg"));
// --> ['image/*']

// charset suffix is ignored
// $ExpectType boolean
match("application/json", "application/json; charset=utf-8");
// --> true
17 changes: 17 additions & 0 deletions types/mime-match/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"private": true,
"name": "@types/mime-match",
"version": "1.0.9999",
"projects": [
"https://github.com/DamonOehlman/mime-match"
],
"devDependencies": {
"@types/mime-match": "workspace:."
},
"owners": [
{
"name": "Remco Haszing",
"githubUsername": "remcohaszing"
}
]
}
19 changes: 19 additions & 0 deletions types/mime-match/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"compilerOptions": {
"module": "node16",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictFunctionTypes": true,
"strictNullChecks": true,
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"mime-match-tests.ts"
]
}
Loading