Closed ComLock closed 7 months ago
The type is not wrong, one just have to write the code a bit different:
import type {ModifiedNode} from '/lib/xp/node';
import {run} from '/lib/xp/context';
import {connect} from '/lib/xp/node';
interface SpecificNodeData {
key: string
}
run({
principals: ['role:system.admin'],
}, () => {
const writeConnection = connect({
repoId: 'com.enonic.app.explorer.collection.a',
branch: 'master'
});
const modifiedNode = writeConnection.modify<SpecificNodeData>({
key: 'ed28007b-f297-4162-86eb-9df020d85ee3',
editor: (node) => {
const modifiedNode: ModifiedNode<SpecificNodeData> = node;
modifiedNode._indexConfig = {
default: 'byType',
}
return modifiedNode;
}
});
log.info('modifiedNode:%s', JSON.stringify(modifiedNode, null, 4))
});
This runs fine:
But shows type error in code editor.