Merge pull request #7471 from aleung/field

Add typing for field
This commit is contained in:
Horiuchi_H
2016-01-04 17:28:23 +09:00
2 changed files with 37 additions and 0 deletions
+28
View File
@@ -0,0 +1,28 @@
// From https://github.com/jprichardson/field/blob/e968fd979ba1a06e35571695ddfdad513e516eae/README.md
/// <reference path="field.d.ts" />
// get
const config = {
environment: {
production: {
port: 80
}
}
}
console.log(field.get(config, 'environment:production:port'))
// => 80
// set
var database: any = {}
console.log(field.get(database, 'production.port'))
// => undefined
// will return undefined since it never existed before
field.set(database, 'production.port', 27017)
console.log(database.production.port)
// => 27017
+9
View File
@@ -0,0 +1,9 @@
// Type definitions for field 1.0.1
// Project: https://www.npmjs.com/package/field
// Definitions by: Leo Liang <https://github.com/aleung/DefinitelyTyped>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare module field {
export function get(topObj: any, fields: string): any;
export function set(topObj: any, fields: string, value: any): any;
}