updated typings

This commit is contained in:
sclausen
2016-02-01 12:59:24 +01:00
parent 717a5fdb07
commit 009d2996f2
2 changed files with 62 additions and 2 deletions
+25
View File
@@ -3,12 +3,31 @@
import yaml = require('js-yaml');
import LoadOptions = yaml.LoadOptions;
import DumpOptions = yaml.DumpOptions;
import TypeConstructorOptions = yaml.TypeConstructorOptions;
import SchemaDefinition = yaml.SchemaDefinition;
var bool: boolean;
var num: number;
var str: string;
var obj: Object;
var value: any;
var array: any[];
var fn: Function;
var schemaDefinition: SchemaDefinition = {
implicit: array,
explicit: array,
include: array
};
var typeConstructorOptions: TypeConstructorOptions = {
kind: str,
resolve: fn,
construct: fn,
instanceOf: obj,
predicate: str,
represent: fn,
defaultStyle: str,
styleAliases: obj
};
var loadOpts: LoadOptions;
var dumpOpts: DumpOptions;
@@ -20,6 +39,8 @@ yaml.JSON_SCHEMA;
yaml.CORE_SCHEMA;
yaml.DEFAULT_SAFE_SCHEMA;
yaml.DEFAULT_FULL_SCHEMA;
yaml.MINIMAL_SCHEMA;
yaml.SAFE_SCHEMA;
// -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
@@ -82,3 +103,7 @@ value = yaml.safeDump(str, dumpOpts);
value = yaml.dump(str);
value = yaml.dump(str, dumpOpts);
value = new yaml.YAMLException();
value = new yaml.Type(str, typeConstructorOptions);
value = yaml.Schema.create(schemaDefinition);
+37 -2
View File
@@ -1,3 +1,5 @@
// Compiled using typings@0.6.4
// Source: https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/52318243888c4aa02b3c0b5e68631577728ffcf8/js-yaml/js-yaml.d.ts
// Type definitions for js-yaml 3.0.2
// Project: https://github.com/nodeca/js-yaml
// Definitions by: Bart van der Schoor <https://github.com/Bartvds>
@@ -7,11 +9,20 @@ declare module jsyaml {
export function safeLoad(str: string, opts?: LoadOptions): any;
export function load(str: string, opts?: LoadOptions): any;
export class Type implements TypeConstructorOptions {
constructor(tag: string, opts?: TypeConstructorOptions);
tag: string;
}
export class Schema {
constructor(definition: SchemaDefinition);
public static create(... any): Schema;
}
export function safeLoadAll(str: string, iterator: (doc: any) => void, opts?: LoadOptions): any;
export function loadAll(str: string, iterator: (doc: any) => void, opts?: LoadOptions): any;
export function safeDump(obj: any, opts?: DumpOptions): string;
export function dump(obj: any, opts?: DumpOptions): string
export function dump(obj: any, opts?: DumpOptions): string;
export interface LoadOptions {
// string to be used as a file path in error/warning messages.
@@ -29,12 +40,29 @@ declare module jsyaml {
skipInvalid?: boolean;
// specifies level of nesting, when to switch from block to flow style for collections. -1 means block style everwhere
flowLevel?: number;
// Each tag may have own set of styles. - "tag" => "style" map.
// Each tag may have own set of styles. - "tag" => "style" map.
styles?: Object;
// specifies a schema to use.
schema?: any;
}
export interface TypeConstructorOptions {
kind?: string;
resolve?: Function;
construct?: Function;
instanceOf?: Object;
predicate?: string;
represent?: Function;
defaultStyle?: string;
styleAliases?: Object;
}
export interface SchemaDefinition {
implicit?: any[];
explicit?: any[];
include?: any[];
}
// only strings, arrays and plain objects: http://www.yaml.org/spec/1.2/spec.html#id2802346
export var FAILSAFE_SCHEMA: any;
// only strings, arrays and plain objects: http://www.yaml.org/spec/1.2/spec.html#id2802346
@@ -45,6 +73,13 @@ declare module jsyaml {
export var DEFAULT_SAFE_SCHEMA: any;
// all supported YAML types.
export var DEFAULT_FULL_SCHEMA: any;
export var MINIMAL_SCHEMA: any;
export var SAFE_SCHEMA: any;
export class YAMLException extends Error {
constructor(reason?: any, mark?: any);
toString(compact?: boolean): string;
}
}
declare module 'js-yaml' {