在 @angular-devkit/schematics自述文件中,我对 ClassOptions 在做什么感到困惑。
如果将代码添加到项目中,则会显示错误,因为该文件不存在。
关于这用于+示例的想法?
import { strings } from '@angular-devkit/core';
import {
Rule, SchematicContext, SchematicsException, Tree,
apply, branchAndMerge, mergeWith, template, url,
} from '@angular-devkit/schematics';
import { Schema as ClassOptions } from './schema';
export default function (options: ClassOptions): Rule {
return (tree: Tree, context: SchematicContext) => {
if (!options.name) {
throw new SchematicsException('Option (name) is required.');
}
const templateSource = apply(
url('./files'),
[
template({
...strings,
...options,
}),
]
);
return branchAndMerge(mergeWith(templateSource));
};
}