Skip to content

Commit

Permalink
fix(xml): use the type system to verify version
Browse files Browse the repository at this point in the history
Reverts: 78ed4ac
  • Loading branch information
lishaduck committed Jun 7, 2024
1 parent 52d3ad2 commit c78f0aa
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
4 changes: 2 additions & 2 deletions xml/_types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ export type xml_node = {
/** XML document. */
export type xml_document = xml_node & {
/** XML version. */
["@version"]?: string
["@version"]?: `1.${number}`
/** XML character encoding. */
["@encoding"]?: string
/** XML standalone. */
["@standalone"]?: string
["@standalone"]?: "yes" | "no"
/** XML doctype. */
["#doctype"]?: xml_node
/** XML instructions. */
Expand Down
17 changes: 17 additions & 0 deletions xml/_types_test.ts
Original file line number Diff line number Diff line change
@@ -1 +1,18 @@
import "./_types.ts"
import { stringify } from "./mod.ts"

// Verify that the generic type is correctly inferred.
const _example = stringify({
"@version": "1.1",
"@encoding": "UTF-8",
"@standalone": "yes",
"#doctype": {
"~name": "html",
"~children": [],
"#text": "",
},
"#instructions": {},
"~name": "html",
"~children": [],
"#text": "",
})

0 comments on commit c78f0aa

Please sign in to comment.