mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-06-28 14:20:12 +00:00
Adds @types/cfenv (#42503)
* adds types for cfenv * changes AppEnv from exported class to interface
This commit is contained in:
34
types/cfenv/cfenv-tests.ts
Normal file
34
types/cfenv/cfenv-tests.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
import * as cfenv from 'cfenv';
|
||||
|
||||
const appEnv = cfenv.getAppEnv(); // $ExpectType AppEnv
|
||||
|
||||
cfenv.getAppEnv({}); // $ExpectType AppEnv
|
||||
cfenv.getAppEnv({ name: 'foo' }); // $ExpectType AppEnv
|
||||
cfenv.getAppEnv({ protocol: 'foo' }); // $ExpectType AppEnv
|
||||
cfenv.getAppEnv({ vcap: {} }); // $ExpectType AppEnv
|
||||
cfenv.getAppEnv({ vcap: { application: 'foo' } }); // $ExpectType AppEnv
|
||||
cfenv.getAppEnv({ vcap: { services: 'foo' } }); // $ExpectType AppEnv
|
||||
cfenv.getAppEnv({ vcapFile: 'foo' }); // $ExpectType AppEnv
|
||||
|
||||
appEnv.app; // $ExpectType object
|
||||
appEnv.isLocal; // $ExpectType boolean
|
||||
appEnv.name; // $ExpectType string
|
||||
appEnv.port; // $ExpectType number
|
||||
appEnv.bind; // $ExpectType string
|
||||
appEnv.urls; // $ExpectType string[]
|
||||
appEnv.url; // $ExpectType string
|
||||
appEnv.services; // $ExpectType object
|
||||
|
||||
appEnv.toJSON(); // $ExpectType string
|
||||
|
||||
appEnv.getServices(); // $ExpectType { [key: string]: Service; }
|
||||
|
||||
appEnv.getService('foo'); // $ExpectType Service | null
|
||||
appEnv.getService(/foo/); // $ExpectType Service | null
|
||||
|
||||
appEnv.getServiceURL('foo'); // $ExpectType string | null
|
||||
appEnv.getServiceURL(/foo/); // $ExpectType string | null
|
||||
appEnv.getServiceURL('foo', { a: 'b' }); // $ExpectType string | null
|
||||
|
||||
appEnv.getServiceCreds('foo'); // $ExpectType object | null
|
||||
appEnv.getServiceCreds(/foo/); // $ExpectType object | null
|
||||
41
types/cfenv/index.d.ts
vendored
Normal file
41
types/cfenv/index.d.ts
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
// Type definitions for cfenv 1.2
|
||||
// Project: https://github.com/cloudfoundry-community/node-cfenv
|
||||
// Definitions by: Jordan Adams <https://github.com/jordanadams>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
export interface Service {
|
||||
label: string;
|
||||
name: string;
|
||||
plan: string;
|
||||
tags: string[];
|
||||
credentials: object;
|
||||
}
|
||||
|
||||
export interface AppEnv {
|
||||
app: object;
|
||||
isLocal: boolean;
|
||||
name: string;
|
||||
port: number;
|
||||
bind: string;
|
||||
urls: string[];
|
||||
url: string;
|
||||
services: object;
|
||||
|
||||
toJSON: () => string;
|
||||
getServices: () => { [key: string]: Service };
|
||||
getService: (spec: string | RegExp) => Service | null;
|
||||
getServiceURL: (spec: string | RegExp, replacements?: object) => string | null;
|
||||
getServiceCreds: (spec: string | RegExp) => object | null;
|
||||
}
|
||||
|
||||
export interface GetAppEnvOptions {
|
||||
name?: string;
|
||||
protocol?: string;
|
||||
vcap?: {
|
||||
application?: string;
|
||||
services?: string;
|
||||
};
|
||||
vcapFile?: string;
|
||||
}
|
||||
|
||||
export function getAppEnv(options?: GetAppEnvOptions): AppEnv;
|
||||
23
types/cfenv/tsconfig.json
Normal file
23
types/cfenv/tsconfig.json
Normal file
@@ -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",
|
||||
"cfenv-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/cfenv/tslint.json
Normal file
1
types/cfenv/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user