Skip to content

[WIP] Emitting Declarations for React Components requires type annotation #1086

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Copilot
Copy link

@Copilot Copilot AI commented Jun 6, 2025

Thanks for assigning this issue to me. I'm starting to work on it and will keep this PR's description up to date as I form a plan and make progress.

Original issue description:

When trying to emit declarations for a React package, tsgo requires type annotations for React Components.

Example component being used:

/* src/index.tsx */
export const MyComponent = () => {
  return <div>Hello World</div>
}

tsconfig.json being used:

{
  "include": ["src/**/*.ts", "src/**/*.tsx"],
  "exclude": ["node_modules"],
  "compilerOptions": {
    "target": "es6",
    "jsx": "react-jsx",
    "forceConsistentCasingInFileNames": true,
    "noEmit": false,
    "esModuleInterop": true,
    "incremental": false,
    "isolatedModules": true,
    "module": "esnext",
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "skipLibCheck": true,
    "strict": true
  }
}

Command:

tsgo -p tsconfig.json --emitDeclarationOnly --declaration --outDir out

The following command produces:

The inferred type of 'MyComponent' cannot be named without a reference to '../node_modules/@types/react/jsx-runtime.js'. This is likely not portable. A type annotation is necessary.

Running the same with tsc produces no errors.

Fixes #1011.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Emitting Declarations for React Components requires type annotation
2 participants