Skip to content

Codemod guesses local Context.Provider ownership from export names #2608

Closed

Description

@domgan-oai

Reproduction

Select only Badge.tsx for the codemod in a project that uses the automatic React JSX runtime.

data.ts

export const BadgeContext = {
	Provider() {
		return 'original';
	},
};

Badge.tsx

import { BadgeContext as Badge } from './data';

const provide = Badge.Provider;
export function View() {
	return <b title={provide()}>Badge</b>;
}

The codemod reports Strong with no findings and changes const provide = Badge.Provider to const provide = Badge. Production React SSR and the browser render the title original. Octane SSR and the client throw because the rewritten value is an object. Selecting both files through a TypeScript path alias reproduces the same mistake.

The inverse occurs for a real context exported under an ordinary name. If both modules are selected and a TypeScript alias resolves to export const Shade = createContext('default'), the migrated consumer retains <Shade.Provider> even though the exporter now produces an Octane context. The equivalent relative import is rewritten correctly.

Expected behavior

Use the selected export and project resolution to recognize a migrated local context. Keep ordinary provider members and unselected local modules intact. An unselected React context still needs a renderer ownership decision before native consumers can read it.

Codex task · Host com-79386

Activity

  1. added
    bug
    agent-authored
    on Nov 13, 2026
  2. domgan-oai commented on Nov 13, 2026

    @domgan-oai
    ContributorAuthor

    #2610 addresses the name-based rewrite of ordinary local provider members. The newly recognized genuine alias remains open.

    A stable declaration and a correctly resolved module do not establish that the original React .Provider member is unchanged. In a synthetic production check, an unselected module imported the same genuine context and installed a getter on .Provider. React SSR and the client rendered the replacement. Rewriting the selected caller from <Shade.Provider> to <Shade> bypassed the getter and rendered the original value.

    The positive rewrite needs either a proof that the original member cannot be replaced through a reachable caller or an explicit producer contract. The selected-module test keeps the existing relative and suffix-alias cases while avoiding new alias rewrites.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent-authoredbug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions