I am creating a library containing schematics. It compiles, but when I try to use it, after prompting all requested inputs, I obtain this error:
Cannot read properties of undefined (reading 'match')
This is my index.ts
import {
Rule, Tree,
apply, url, applyTemplates, move,
chain, mergeWith
} from '@angular-devkit/schematics';
import {strings, normalize} from '@angular-devkit/core';
import {Schema as WrapSchema} from './schema';
export function wrap(options: WrapSchema): Rule {
return async (_tree: Tree) => {
const templateSource = apply(url('./files'), [
applyTemplates({
classify: strings.classify,
dasherize: strings.dasherize,
name: options.name,
props: options.props?.trim().split(','),
listeners: options.listeners?.trim().split(',')
}),
move(normalize(options.path as string))
]);
return chain([
mergeWith(templateSource)
]);
};
}
All the options are correctly defined in the schema.
The schematics used to work before I changed the template. Here is the template file:
import {
Component,
ViewEncapsulation,
Input,
Output,
ElementRef,
EventEmitter
} from '@angular/core';
import {Wrapper} from 'my-lib';
@Component({
selector: 'app-<%= dasherize(name) %>',
template: ``,
encapsulation: ViewEncapsulation.None
})
export class <%= classify(name) %>Component extends Wrapper {
<% if(!!props) { props.forEach((prop) => { %>@Input() <%= prop %>: any;
<% })} %>
<% if(!!listeners){ listeners.forEach((listener) => { %>@Output() <%= listener %>Event = new EventEmitter<any>();
<%= listener %> = (e: any) => {
this.<%= listener =>Event.emit(e);
}
<% })} %>
constructor(private containerRef: ElementRef) {
super(containerRef)
}
protected render() {
const {<%= props %>,<%= listeners %>} = this;
this.root?.render(<<%= classify(name) %>
<% if(!!props) { props.forEach((prop) => { %><%= prop %>={<%= prop %>}
<% })} %> <% if(!!listeners) { listeners.forEach((listener) => { %><%= listener %> = { (e) => <%= listener %>(e)}
<% })} %>
></<%= classify(name) %>>);
}
}
Nowhere in my code I call any match
method