Skip to content

JSX key prop rejected when using jsxImportSource: smithers-orchestrator #81

@enitrat

Description

@enitrat

Bug

When jsxImportSource is set to "smithers-orchestrator", TypeScript rejects the key prop on mapped Smithers components:

Property 'key' does not exist on type 'SequenceProps'

Intrinsic elements (like <div>) can also lose type information under this setup.

Root cause

smithers-orchestrator/jsx-runtime re-exports runtime functions (jsx, jsxs, Fragment, jsxDEV) but does not export a JSX namespace. TypeScript expects jsxImportSource modules to provide JSX.IntrinsicAttributes (which includes key), JSX.IntrinsicElements, etc. Without them, key/ref are not merged and are checked directly against component props.

Minimal Reproducible Example

package.json

{
  "dependencies": {
    "smithers-orchestrator": "latest",
    "react": "^19.0.0",
    "@types/react": "^19.0.0",
    "typescript": "^5.8.0"
  }
}

tsconfig.json

{
  "compilerOptions": {
    "strict": true,
    "target": "ESNext",
    "module": "ESNext",
    "moduleResolution": "bundler",
    "jsx": "react-jsx",
    "jsxImportSource": "smithers-orchestrator",
    "noEmit": true,
    "skipLibCheck": true
  },
  "include": ["src"]
}

src/bug.tsx

import type { ReactNode } from "react";

type SequenceProps = { skipIf?: boolean; children?: ReactNode };
declare function Sequence(props: SequenceProps): ReactNode;

const items = [1, 2, 3];

// ERROR: Property 'key' does not exist on type 'SequenceProps'
export const demo = (
  <>
    {items.map((n) => (
      <Sequence key={`s-${n}`} skipIf={false}>
        <div>{n}</div>
      </Sequence>
    ))}
  </>
);

Reproduce:

npm install && npx tsc --noEmit

Expected: compiles cleanly (as it does with jsxImportSource: "react")
Actual:

src/bug.tsx: error TS2322: Type '{ key: string; skipIf: false; children: Element; }'
  is not assignable to type 'SequenceProps'.
  Property 'key' does not exist on type 'SequenceProps'.

Related

PR #80 addresses this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions