Skip to content

Commit

Permalink
feat(hiccup): enable TS strict compiler flags (refactor)
Browse files Browse the repository at this point in the history
  • Loading branch information
postspectacular committed Jun 4, 2019
1 parent 787e2d4 commit d0fce75
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
20 changes: 13 additions & 7 deletions packages/hiccup/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export const XHTML_NS = "http://www.w3.org/1999/xhtml";

export const TAG_REGEXP = /^([^\s\.#]+)(?:#([^\s\.#]+))?(?:\.([^\s#]+))?$/;

export const PROC_TAGS = {
export const PROC_TAGS: { [id: string]: string } = {
"?xml": "?>\n",
"!DOCTYPE": ">\n",
"!ENTITY": ">\n",
Expand All @@ -13,16 +13,20 @@ export const PROC_TAGS = {
};

// tslint:disable-next-line
export const SVG_TAGS = "animate animateColor animateMotion animateTransform circle clipPath color-profile defs desc discard ellipse feBlend feColorMatrix feComponentTransfer feComposite feConvolveMatrix feDiffuseLighting feDisplacementMap feDistantLight feDropShadow feFlood feFuncA feFuncB feFuncG feFuncR feGaussianBlur feImage feMerge feMergeNode feMorphology feOffset fePointLight feSpecularLighting feSpotLight feTile feTurbulence filter font foreignObject g image line linearGradient marker mask metadata mpath path pattern polygon polyline radialGradient rect set stop style svg switch symbol text textPath title tref tspan use view"
export const SVG_TAGS: {
[id: string]: number;
} = "animate animateColor animateMotion animateTransform circle clipPath color-profile defs desc discard ellipse feBlend feColorMatrix feComponentTransfer feComposite feConvolveMatrix feDiffuseLighting feDisplacementMap feDistantLight feDropShadow feFlood feFuncA feFuncB feFuncG feFuncR feGaussianBlur feImage feMerge feMergeNode feMorphology feOffset fePointLight feSpecularLighting feSpotLight feTile feTurbulence filter font foreignObject g image line linearGradient marker mask metadata mpath path pattern polygon polyline radialGradient rect set stop style svg switch symbol text textPath title tref tspan use view"
.split(" ")
.reduce((acc, x) => ((acc[x] = 1), acc), {});
.reduce((acc: any, x) => ((acc[x] = 1), acc), {});

// tslint:disable-next-line
export const VOID_TAGS = "area base br circle col command ellipse embed hr img input keygen line link meta param path polygon polyline rect source stop track use wbr ?xml"
export const VOID_TAGS: {
[id: string]: number;
} = "area base br circle col command ellipse embed hr img input keygen line link meta param path polygon polyline rect source stop track use wbr ?xml"
.split(" ")
.reduce((acc, x) => ((acc[x] = 1), acc), {});
.reduce((acc: any, x) => ((acc[x] = 1), acc), {});

export const ENTITIES = {
export const ENTITIES: { [id: string]: string } = {
"&": "&",
"<": "&lt;",
">": "&gt;",
Expand All @@ -32,7 +36,9 @@ export const ENTITIES = {

export const COMMENT = "__COMMENT__";

export const NO_SPANS = {
export const NO_SPANS: {
[id: string]: number;
} = {
button: 1,
option: 1,
text: 1,
Expand Down
10 changes: 8 additions & 2 deletions packages/hiccup/src/serialize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@ import {
isString
} from "@thi.ng/checks";
import { illegalArgs } from "@thi.ng/errors";
import { COMMENT, NO_SPANS, PROC_TAGS, TAG_REGEXP, VOID_TAGS } from "./api";
import {
COMMENT,
NO_SPANS,
PROC_TAGS,
TAG_REGEXP,
VOID_TAGS
} from "./api";
import { css } from "./css";
import { escape } from "./escape";

Expand Down Expand Up @@ -153,7 +159,7 @@ const _serialize = (
span: boolean,
keys: boolean,
path: any[]
) => {
): string => {
if (tree == null) {
return "";
}
Expand Down

0 comments on commit d0fce75

Please sign in to comment.