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
24 changes: 24 additions & 0 deletions types/android-device-list/android-device-list-tests.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import {
deviceList,
brandList,
getDevicesByBrand,
getDevicesByDeviceId,
getDevicesByModel,
getDevicesByName,
} from "android-device-list";

deviceList(); // $ExpectType Device[]
brandList(); // $ExpectType string[]
getDevicesByBrand("LG"); // $ExpectType Device[]
getDevicesByBrand("LG", {}); // $ExpectType Device[]
// $ExpectType Device[]
getDevicesByBrand("LG", {
caseInsensitive: true,
contains: true,
});
getDevicesByDeviceId("deviceId"); // $ExpectType Device[]
getDevicesByModel("model", {}); // $ExpectType Device[]
// $ExpectType Device[]
getDevicesByName("model", {
caseInsensitive: true,
});
55 changes: 55 additions & 0 deletions types/android-device-list/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// Type definitions for android-device-list 1.2
// Project: https://github.com/pbakondy/android-device-list#readme
// Definitions by: Piotr Błażejewicz <https://github.com/peterblazejewicz>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped

/**
* Returns the full device list
*/
export function deviceList(): Device[];

/**
* Returns the full brand list
*/
export function brandList(): string[];

/**
* Returns a device list with matching retail brand.
*/
export function getDevicesByBrand(brand: string, options?: Options): Device[];

/**
* Returns a device list with matching marketing name.
*/
export function getDevicesByName(name: string, options?: Options): Device[];

/**
* Returns a device list with matching build.os.DEVICE.
*/
export function getDevicesByDeviceId(deviceId: string, options?: Options): Device[];

/**
* Returns a device list with matching build.os.MODEL.
*/
export function getDevicesByModel(model: string, Options?: Options): Device[];

export interface Options {
/**
* do not care of case type
* @default false
*/
caseInsensitive?: boolean;

/**
* return partial (substring) results too
* @default false
*/
contains?: boolean;
}

export interface Device {
brand: string;
name: string;
device: string;
model: string;
}
23 changes: 23 additions & 0 deletions types/android-device-list/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictFunctionTypes": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"android-device-list-tests.ts"
]
}
1 change: 1 addition & 0 deletions types/android-device-list/tslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
17 changes: 17 additions & 0 deletions types/android-versions/android-versions-tests.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import android = require("android-versions");

android.get(23); // $ExpectType AndroidVersion | null

android.BASE; // $ExpectType AndroidVersion
android.R; // $ExpectType AndroidVersion
android.VERSIONS; // $ExpectType Record<VersionCode, AndroidVersion>

// $ExpectType AndroidVersion[] | null
android.getAll(version => {
return version.ndk > 5 && version.api < 15;
});

// $ExpectType AndroidVersion
android.get(version => {
return version.ndk > 5 && version.api < 15;
})!;
89 changes: 89 additions & 0 deletions types/android-versions/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
// Type definitions for android-versions 1.6
// Project: https://github.com/dvoiss/android-versions#readme
// Definitions by: Piotr Błażejewicz <https://github.com/peterblazejewicz>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped

/**
* A module to get Android versions by API level, NDK level, semantic version, or version name.
*
* Versions are referenced from here:
* {@link https://source.android.com/source/build-numbers.html#platform-code-names-versions-api-levels-and-ndk-releases}
* {@link https://github.com/android/platform_frameworks_base/blob/master/core/java/android/os/Build.java}
*
* The version for "Current Development Build" ("CUR_DEVELOPMENT") is not included.
*/

declare namespace android {
interface AndroidVersion {
api: number;
ndk: number;
semver: string;
name: string;
versionCode: string;
}
type VersionCode =
| "BASE"
| "BASE_1_1"
| "CUPCAKE"
| "DONUT"
| "ECLAIR"
| "ECLAIR_0_1"
| "ECLAIR_MR1"
| "FROYO"
| "GINGERBREAD"
| "GINGERBREAD_MR1"
| "HONEYCOMB"
| "HONEYCOMB_MR1"
| "HONEYCOMB_MR2"
| "ICE_CREAM_SANDWICH"
| "ICE_CREAM_SANDWICH_MR1"
| "JELLY_BEAN"
| "JELLY_BEAN_MR1"
| "JELLY_BEAN_MR2"
| "KITKAT"
| "KITKAT_WATCH"
| "LOLLIPOP"
| "LOLLIPOP_MR1"
| "M"
| "N"
| "N_MR1"
| "O"
| "O_MR1"
| "P"
| "Q"
| "R";

type MapVersionSupport = {
[K in VersionCode]: AndroidVersion;
};
}

declare const android: {
VERSIONS: Record<android.VersionCode, android.AndroidVersion>;
/**
* Retrieve a single Android version.
* @param arg - The value or predicate to use to retrieve values.
* @return An object representing the version found or null if none found.
*/
get: (
arg:
| {
toString(): string;
}
| ((version: android.AndroidVersion) => boolean),
) => android.AndroidVersion | null;
/**
* Retrieve all Android versions that meet the criteria of the argument.
* @param arg - The value or predicate to use to retrieve values.
* @return An object representing the version found or null if none found.
*/
getAll: (
arg:
| {
toString(): string;
}
| ((version: android.AndroidVersion) => boolean),
) => android.AndroidVersion[] | null;
} & android.MapVersionSupport;

export = android;
23 changes: 23 additions & 0 deletions types/android-versions/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictFunctionTypes": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"android-versions-tests.ts"
]
}
1 change: 1 addition & 0 deletions types/android-versions/tslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
Loading