mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-06 15:57:13 +00:00
Fix to explicitly set Type Class field
This commit is contained in:
Vendored
+11
-6
@@ -7,12 +7,17 @@
|
||||
export function safeLoad(str: string, opts?: LoadOptions): any;
|
||||
export function load(str: string, opts?: LoadOptions): any;
|
||||
|
||||
export class Type {
|
||||
export class Type implements TypeConstructorOptions {
|
||||
constructor(tag: string, opts?: TypeConstructorOptions);
|
||||
tag: string;
|
||||
kind: string | null;
|
||||
resolve(data: any): boolean;
|
||||
construct(data: any): any;
|
||||
instanceOf: object | null;
|
||||
predicate: string | null;
|
||||
represent: ((data: object) => any) | { [x: string]: (data: object) => any; } | null;
|
||||
defaultStyle: string | null;
|
||||
styleAliases: { [x: string]: any; };
|
||||
}
|
||||
/* tslint:disable-next-line:no-empty-interface */
|
||||
export interface Type extends TypeConstructorOptions { }
|
||||
|
||||
/* tslint:disable-next-line:no-unnecessary-class */
|
||||
export class Schema implements SchemaDefinition {
|
||||
@@ -73,8 +78,8 @@ export interface TypeConstructorOptions {
|
||||
|
||||
export interface SchemaDefinition {
|
||||
implicit?: any[];
|
||||
explicit?: any[];
|
||||
include?: any[];
|
||||
explicit?: Type[];
|
||||
include?: Schema[];
|
||||
}
|
||||
|
||||
// only strings, arrays and plain objects: http://www.yaml.org/spec/1.2/spec.html#id2802346
|
||||
|
||||
@@ -7,10 +7,13 @@ import SchemaDefinition = yaml.SchemaDefinition;
|
||||
let bool: boolean;
|
||||
let num: number;
|
||||
let str: string;
|
||||
let obj: { [x: string]: any; };
|
||||
let obj: object;
|
||||
let map: { [x: string]: any; };
|
||||
let value: any;
|
||||
let array: any[];
|
||||
let fn: (...args: any[]) => any;
|
||||
let fnOrFnMap: ((...args: any[]) => any) | { [x: string]: (...args: any[]) => any; };
|
||||
let type: yaml.Type;
|
||||
let schemaDefinition: SchemaDefinition = {
|
||||
implicit: array,
|
||||
explicit: array,
|
||||
@@ -72,6 +75,17 @@ dumpOpts = {
|
||||
|
||||
// -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
|
||||
|
||||
str = type.kind;
|
||||
fn = type.resolve;
|
||||
fn = type.construct;
|
||||
obj = type.instanceOf;
|
||||
str = type.predicate;
|
||||
fnOrFnMap = type.represent;
|
||||
str = type.defaultStyle;
|
||||
map = type.styleAliases;
|
||||
|
||||
// -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
|
||||
|
||||
value = yaml.safeLoad(str);
|
||||
value = yaml.safeLoad(str, loadOpts);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user