mirror of
https://github.com/denoland/deno.git
synced 2025-08-30 23:38:03 +00:00
chore: add code generation for @types/deno (#25545)
This commit is contained in:
parent
e1c8d2755e
commit
33f169beb9
19 changed files with 485 additions and 356 deletions
|
@ -45,33 +45,39 @@ for (const file of project.getSourceFiles()) {
|
|||
}
|
||||
|
||||
const parent = node.getFirstAncestorByKind(ts.SyntaxKind.ModuleDeclaration);
|
||||
const isInterfaceOrType =
|
||||
node.getKind() === ts.SyntaxKind.InterfaceDeclaration ||
|
||||
node.getKind() === ts.SyntaxKind.TypeAliasDeclaration;
|
||||
|
||||
if (parent) {
|
||||
if (!node.isExported()) {
|
||||
errors.push(getErrorPrefix(node) + "export keyword");
|
||||
errors.push(getMissingErrorPrefix(node) + "export keyword");
|
||||
continue;
|
||||
}
|
||||
} else if (!node.hasDeclareKeyword()) {
|
||||
errors.push(getErrorPrefix(node) + "declare keyword");
|
||||
} else if (!isInterfaceOrType && !node.hasDeclareKeyword()) {
|
||||
errors.push(getMissingErrorPrefix(node) + "declare keyword");
|
||||
continue;
|
||||
} else if (isInterfaceOrType && node.hasDeclareKeyword()) {
|
||||
errors.push(getErrorPrefix(node) + "has incorrect declare keyword");
|
||||
continue;
|
||||
}
|
||||
|
||||
const jsDoc = node.getFirstChildIfKind(ts.SyntaxKind.JSDoc);
|
||||
if (!jsDoc) {
|
||||
errors.push(getErrorPrefix(node) + "JSDoc comment");
|
||||
errors.push(getMissingErrorPrefix(node) + "JSDoc comment");
|
||||
continue;
|
||||
}
|
||||
|
||||
const tags = jsDoc.getTags();
|
||||
|
||||
if (!tags.find((tag) => tag.getTagName() === "category")) {
|
||||
errors.push(getErrorPrefix(node) + "JSDoc @category tag");
|
||||
errors.push(getMissingErrorPrefix(node) + "JSDoc @category tag");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (unstableFiles.includes(file)) {
|
||||
if (!tags.find((tag) => tag.getTagName() === "experimental")) {
|
||||
errors.push(getErrorPrefix(node) + "JSDoc @experimental tag");
|
||||
errors.push(getMissingErrorPrefix(node) + "JSDoc @experimental tag");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -81,6 +87,10 @@ if (errors.length > 0) {
|
|||
throw new AggregateError(errors);
|
||||
}
|
||||
|
||||
function getErrorPrefix(node) {
|
||||
return `Symbol at file://${node.getSourceFile().getFilePath()}:${node.getStartLineNumber()} is missing a `;
|
||||
function getMissingErrorPrefix(node) {
|
||||
return getErrorPrefix(node) + `is missing a `;
|
||||
}
|
||||
|
||||
function getErrorPrefix(node) {
|
||||
return `Symbol at file://${node.getSourceFile().getFilePath()}:${node.getStartLineNumber()} `;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue