feat: Add w3c‑xmlserializer (#41389)

This commit is contained in:
ExE Boss
2020-01-07 17:00:56 -08:00
committed by Armando Aguirre
parent 02dea6062f
commit e816b95a87
4 changed files with 48 additions and 0 deletions
+19
View File
@@ -0,0 +1,19 @@
// Type definitions for w3c-xmlserializer 2.0
// Project: https://github.com/jsdom/w3c-xmlserializer#readme
// Definitions by: ExE Boss <https://github.com/ExE-Boss>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare namespace serialize {
interface Options {
/**
* Whether the serialization algorithm will throw an `Error`
* when the `Node` can't be serialized to well-formed XML.
*
* @default false
*/
requireWellFormed?: boolean;
}
}
declare function serialize(root: Node, options?: serialize.Options): string;
export = serialize;
+19
View File
@@ -0,0 +1,19 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": ["es5", "dom"],
"noImplicitAny": true,
"noImplicitThis": true,
"strictFunctionTypes": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": ["../"],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"w3c-xmlserializer-tests.ts",
"index.d.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
@@ -0,0 +1,9 @@
import serialize = require('w3c-xmlserializer');
serialize(document); // $ExpectType string
serialize(document.documentElement); // $ExpectType string
serialize(window); // $ExpectError
serialize(document, { requireWellFormed: true }); // $ExpectType string
serialize(document.documentElement, { requireWellFormed: true }); // $ExpectType string
serialize(window, { requireWellFormed: true }); // $ExpectError