TypL
TypL copied to clipboard
Split checker into multiple files
For the purposes of better readability, easier branching merging and easier developer onboarding, it would be useful to split the checker.js into multiple files.
For example,
var collectTypesVisitors = {
TaggedTemplateExpression(path) {
if (T.isIdentifier(path.node.tag)) {
let tagName = path.node.tag.name;
if (recognizedTypeIDs.includes(tagName)) {
nodeTypes.set(path.node,{ tagged: tagName, });
}
}
},
TemplateLiteral(path) {
if (T.isTaggedTemplateExpression(path.parent)) {
let parentType = nodeTypes.get(path.parent);
if (parentType) {
nodeTypes.set(path.node,{ ...parentType, });
}
else {
nodeTypes.set(path.node,{ inferred: "unknown", });
}
}
else {
nodeTypes.set(path.node,{ inferred: "string", });
}
},
//... etc...
}
could be split on a "per visitor type" basis.
var collectTypesVisitors = {
TaggedTemplateExpression: require('checkTaggedTemplateExpression'),
TemplateLiteral: require('checkTemplateLiteral'),
}
Or something similar.
That way for example, a developer or a group of developers could focus on documentation, tests, and code only related to one visitor type, without ever affecting the rest of the code.