Remove unused code; handle escaped and double-escaped script data; allow using buffer instead of string source for bench; enforce matching tags

This commit is contained in:
Wilson Lin 2020-01-10 18:30:49 +11:00
commit e966f9a23b
15 changed files with 97 additions and 81 deletions

View file

@ -23,25 +23,16 @@ const fetchReactTypingsSource = async () => {
};
const processReactTypeDeclarations = async (source) => {
let tagNameToInterfaceMap;
let booleanAttributes = new Map();
const unvisited = [source];
while (unvisited.length) {
const node = unvisited.shift();
let matches;
switch (node.kind) {
case ts.SyntaxKind.InterfaceDeclaration:
const name = node.name.escapedText;
if (name === "ReactHTML") {
// Each member of ReactHTML looks something like:
//
// area: DetailedHTMLFactory<AreaHTMLAttributes<HTMLAreaElement>, HTMLAreaElement>;
// ^^^^ [1] ^^^^^^^^^^^^^^^ [2]
//
// Get mapping from tag name [1] to interface name [2].
tagNameToInterfaceMap = Object.fromEntries(node.members.map(m => [m.name.escapedText, m.type.typeArguments[1].typeName.escapedText]));
} else if ((matches = /^([A-Za-z]+)HTMLAttributes/.exec(name))) {
let matches;
if ((matches = /^([A-Za-z]+)HTMLAttributes/.exec(name))) {
const tagName = matches[1].toLowerCase();
if (!['all', 'webview'].includes(tagName)) {
node.members

View file

@ -1,6 +1,5 @@
{
"COMMENT_END": "-->",
"SCRIPT_END": "</script",
"STYLE_END": "</style",
"INSTRUCTION_END": "?>"
}