You need to review a small PR in a TypeScript 5.8 module for Node.js 22 in ES modules mode with strict=true.
Feature context: the module stores profile templates by role and returns new drafts for an edit form. Public API:
registerTemplate(role, template) — registers or updates a role template.createDraft(role, overrides?) — returns a new profile draft based on the template and partial overrides.renameTag(profile, from, to) — renames a tag in a specific profile and returns the same profile object.listTemplateRoles() — returns the list of roles that have templates.Functional requirements:
Environment and run:
tsconfig.json: strict=true, target=ES2022, module=NodeNext, moduleResolution=NodeNextHow to reproduce the observed behavior after this PR:
registerTemplate('manager', { displayName: 'Mila', tags: ['ops'], settings: { theme: 'dark', alerts: true } })a = createDraft('manager') and do:
a.tags.push('urgent')a.settings.theme = 'light'b = createDraft('manager')b may already have changed tags or settings, although only a was modified.const roles = listTemplateRoles(); roles.length = 0;listTemplateRoles() call should still return the registered roles.Assumptions:
overrides.tags is provided, it must fully replace the tag list in the draft.Error if the role template is not found.Find exactly two independent problems in the PR changes.
TypeScript 5.8, Node.js 22, ES modules, strict mode (strict=true, module=NodeNext, target=ES2022). No external libraries and no hidden infrastructure.
Use line comments to explain the problem, its impact, the fix and how to test it.