mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-04-14 01:24:26 +00:00
Adds types for version 2.0 of svg-parser (#38474)
* Adds types for new version of svg-parser * Added whitespace for union types * Update types with feedback from mrmlnc * Re-write test to conform with new definitions
This commit is contained in:
committed by
Michael Crane
parent
cf581aef12
commit
e85685ffe0
29
types/svg-parser/index.d.ts
vendored
29
types/svg-parser/index.d.ts
vendored
@@ -1,14 +1,29 @@
|
||||
// Type definitions for svg-parser 1.0
|
||||
// Project: https://gitlab.com/Rich-Harris/svg-parser#README
|
||||
// Type definitions for svg-parser 2.0
|
||||
// Project: https://github.com/Rich-Harris/svg-parser
|
||||
// Definitions by: mrmlnc <https://github.com/mrmlnc>
|
||||
// Joel Shinness <https://github.com/JoelCodes>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.1
|
||||
|
||||
export interface Node {
|
||||
name: string;
|
||||
attributes: Record<string, string | number>;
|
||||
children: Node[];
|
||||
export interface TextNode {
|
||||
type: 'text';
|
||||
value?: string | boolean | number;
|
||||
}
|
||||
|
||||
export interface ElementNode {
|
||||
type: 'element';
|
||||
tagName?: string;
|
||||
properties?: Record<string, string|number>;
|
||||
children: Array<Node | string>;
|
||||
value?: string;
|
||||
metadata?: string;
|
||||
}
|
||||
|
||||
export function parse(content: string): Node;
|
||||
export type Node = TextNode | ElementNode;
|
||||
|
||||
export interface RootNode {
|
||||
type: 'root';
|
||||
children: Node;
|
||||
}
|
||||
|
||||
export function parse(source: string): RootNode;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import * as parser from 'svg-parser';
|
||||
|
||||
// $ExpectType Node
|
||||
// $ExpectType RootNode
|
||||
parser.parse('<svg></svg>');
|
||||
|
||||
Reference in New Issue
Block a user