We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
null
1 parent 63c075b commit 5311151Copy full SHA for 5311151
types/index.d.ts
@@ -1,6 +1,6 @@
1
// TypeScript Version: 3.7
2
3
-import {Element, Node} from 'xast'
+import {Element, Node, Root} from 'xast'
4
5
type Children = string | Node | number | Children[]
6
@@ -19,6 +19,14 @@ type Attributes = Record<string, Primitive>
19
*/
20
declare function xastscript(name: string, ...children: Children[]): Element
21
22
+/**
23
+ * Create XML trees in xast.
24
+ *
25
+ * @param name Qualified name. Case sensitive and can contain a namespace prefix (such as rdf:RDF).
26
+ * @param children (Lists of) child nodes. When strings are encountered, they are mapped to Text nodes.
27
+ */
28
+declare function xastscript(name: null, ...children: Children[]): Root
29
+
30
/**
31
* Create XML trees in xast.
32
*
types/test.ts
@@ -2,12 +2,17 @@ import x = require('xastscript')
x('urlset') // $ExpectType Element
x('urlset', 'string') // $ExpectType Element
+x('urlset', 1) // $ExpectType Element
x('urlset', ['string', 'string']) // $ExpectType Element
7
x('urlset', x('loc'), 'string') // $ExpectType Element
8
x('urlset', x('loc')) // $ExpectType Element
9
x('urlset', x('loc'), x('loc')) // $ExpectType Element
10
x('urlset', [x('loc'), x('loc')]) // $ExpectType Element
11
x('urlset', []) // $ExpectType Element
12
+x(null) // $ExpectType Root
13
+x(null, 'string') // $ExpectType Root
14
+x(null, 1) // $ExpectType Root
15
+x(null, []) // $ExpectType Root
16
17
const xmlns = 'http://www.sitemaps.org/schemas/sitemap/0.9'
18
@@ -30,3 +35,4 @@ x('urlset', {xmlNumberAttribute}, []) // $ExpectType Element
35
x() // $ExpectError
36
x(false) // $ExpectError
37
x('urlset', x('loc'), {xmlns}) // $ExpectError
38
+x(null, {xmlns}) // $ExpectError
0 commit comments