Skip to content

Conversation

Copy link

Copilot AI commented Oct 20, 2025

This PR converts the entire project from JavaScript to TypeScript while maintaining 100% backward compatibility and preserving all existing behavior.

Changes

TypeScript Configuration

  • Added tsconfig.json configured for CommonJS output targeting ES2020
  • Added jest.config.js for TypeScript test support using ts-jest
  • Updated ESLint configuration to support TypeScript parsing with @typescript-eslint plugins

Source Code Conversion

All source files have been converted to TypeScript:

  • index.jsindex.ts
  • create-or-update-files.jscreate-or-update-files.ts
  • create-or-update-files.test.jscreate-or-update-files.test.ts

All types are properly defined using Octokit's type system:

  • Used Octokit type from @octokit/rest for the octokit parameter
  • Used RestEndpointMethodTypes from @octokit/plugin-rest-endpoint-methods for method parameters and return types
  • Defined proper interfaces for Options, Change, FileChange, and CommitResult
  • All function signatures have explicit types from the Octokit API
  • File mode and type properties are restricted to valid literal types

Package Configuration

Updated package.json:

  • Main entry point: index.jsdist/index.js
  • Added types field pointing to dist/index.d.ts for TypeScript consumers
  • Added build scripts: build, prepare
  • Updated lint and test scripts for TypeScript files

Dependencies

Added TypeScript-related dev dependencies:

  • typescript - TypeScript compiler
  • @types/jest, @types/node - Type definitions
  • @typescript-eslint/eslint-plugin, @typescript-eslint/parser - ESLint TypeScript support
  • ts-jest - Jest TypeScript preprocessor

Build Output

The project now builds to the dist/ directory containing:

  • Compiled JavaScript (CommonJS)
  • Type definitions (.d.ts)
  • Source maps

The .gitignore has been updated to exclude build artifacts from version control.

Testing

✅ All 28 existing tests pass without modification
✅ Linting passes with no errors
✅ Build succeeds and generates correct output
✅ Plugin loads correctly from built code
✅ No security vulnerabilities detected

Backward Compatibility

This conversion maintains 100% backward compatibility:

  • No changes to public API or behavior
  • Compiled output is functionally identical to original JavaScript
  • All existing consumers will continue to work without changes
  • TypeScript consumers now get proper type definitions with full type safety

Migration Path

For consumers of this package:

  • JavaScript users: No changes required, everything works as before
  • TypeScript users: Type definitions are now available automatically via the types field in package.json with full type safety using Octokit's type system

Fixes #127

Original prompt

This section details on the original issue you should resolve

<issue_title>Convert project to Typescript</issue_title>
<issue_description>Convert the project to Typescript without changing any behaviour. All existing tests must continue to pass</issue_description>

Comments on the Issue (you are @copilot in this section)

Fixes #127


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Copilot AI changed the title [WIP] Convert project to Typescript while preserving behavior Convert project to TypeScript Oct 20, 2025
Copilot AI requested a review from mheap October 20, 2025 12:34
Copilot finished work on behalf of mheap October 20, 2025 12:34
@mheap
Copy link
Owner

mheap commented Oct 20, 2025

@copilot Do not use any. Research which type to use. You can use types from Octokit directly if needed

Copy link
Author

Copilot AI commented Oct 20, 2025

@copilot Do not use any. Research which type to use. You can use types from Octokit directly if needed

Replaced all any types with proper types from Octokit:

  • Used Octokit type from @octokit/rest for the octokit parameter
  • Used RestEndpointMethodTypes from @octokit/plugin-rest-endpoint-methods for method parameters and return types
  • Defined proper interfaces for Options, Change, FileChange, and CommitResult
  • All function signatures now have explicit types from the Octokit API

Commit: Updated in the latest commit

Copilot finished work on behalf of mheap October 20, 2025 13:01
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.

Convert project to Typescript

2 participants