Skip to main content

typescript/no-unsafe-object-assignment

Deprecated compatibility alias for typescript/no-unsafe-object-assign.

Targeted pattern scope

⚠️ This rule requires type information to run. Configure type-aware linting (parserOptions.project or projectService) before enabling it.

This rule is a TypeScript-prefixed alias of typescript/no-unsafe-object-assign.

It delegates to the canonical rule and reports only when an Object.assign source may write a readonly target key.

What this rule reports

This rule reports the same calls as typescript/no-unsafe-object-assign.

Why this rule exists

The alias remains exported so existing explicit configurations keep working while consumers migrate to the canonical rule ID.

❌ Incorrect

type Target = { readonly x: number };
const target: Target = { x: 1 };
Object.assign(target, { x: 2 });

✅ Correct

type Target = { readonly id: string; count: number };
declare const target: Target;
Object.assign(target, { count: 2 });

Deprecated

Behavior and migration notes

This rule reports only and does not provide an autofix. It remains available for manual compatibility configurations but is excluded from every executable preset so a preset never enables both IDs.

Replace the alias ID with etc-misc/typescript/no-unsafe-object-assign.

Options

This rule has no options.

Additional examples

type Target = { readonly id: string; count: number };
declare const target: Target;
Object.assign(target, { id: "changed" });
// ❌ reported

ESLint flat config example

import etcMisc from "eslint-plugin-etc-misc";

export default [
{
plugins: { "etc-misc": etcMisc },
rules: {
"etc-misc/typescript/no-unsafe-object-assign": "error",
},
},
];

When not to use it

Do not enable this alias in new configurations. Configure the canonical rule instead.

Package documentation

Rule catalog ID: R129

Further reading

Adoption resources

  • Start at warning level in CI, then move to error after cleanup.
  • Use focused codemods/autofix batches per package or directory.