Skip to content

Add TypeScript support with configuration and initial source files#2

Open
rahul-vyas-dev wants to merge 1 commit intoAOSSIE-Org:mainfrom
rahul-vyas-dev:main
Open

Add TypeScript support with configuration and initial source files#2
rahul-vyas-dev wants to merge 1 commit intoAOSSIE-Org:mainfrom
rahul-vyas-dev:main

Conversation

@rahul-vyas-dev
Copy link
Contributor

@rahul-vyas-dev rahul-vyas-dev commented Feb 26, 2026

Adding TS support

Checklist

  • My code follows the project's code style and conventions
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings or errors
  • I have joined the Discord server and I will share a link to this PR with the project maintainers there
  • I have read the Contributing Guidelines

⚠️ AI Notice - Important!

We encourage contributors to use AI tools responsibly when creating Pull Requests. While AI can be a valuable aid, it is essential to ensure that your contributions meet the task requirements, build successfully, include relevant tests, and pass all linters. Submissions that do not meet these standards may be closed without warning to maintain the quality and integrity of the project. Please take the time to understand the changes you are proposing and their impact.

Summary by CodeRabbit

  • Chores
    • Added TypeScript configuration with strict type checking enabled, targeting ES2020 with JSX support.
    • Updated package configuration to include TypeScript as a development dependency.

@github-actions github-actions bot added no-issue-linked PR is not linked to any issue configuration Configuration file changes dependencies Dependency file changes javascript JavaScript/TypeScript code changes size/M Medium PR (51-200 lines changed) repeat-contributor PR from an external contributor who already had PRs merged pending-coderabbit-review labels Feb 26, 2026
@coderabbitai
Copy link

coderabbitai bot commented Feb 26, 2026

Walkthrough

The changes add TypeScript support to the project by updating package.json to reference the TypeScript entry point (src/index.ts) and adding TypeScript as a devDependency, along with creating a tsconfig.json configuration file with compiler settings for ES2020 target and strict type checking.

Changes

Cohort / File(s) Summary
TypeScript Setup Configuration
package.json, tsconfig.json
Updated package.json main entry point from index.js to src/index.ts and added TypeScript ^5.9.3 as devDependency. Created tsconfig.json with ES2020 target, strict mode enabled, React JSX support, ESNext modules, and src directory inclusion.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

Suggested labels

Typescript Lang

Poem

🐰 A leap into types so fine,
TypeScript makes the code align,
With strict rules and configs clear,
Errors vanish, bugs disappear!
ES2020 shines so bright,

🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main changes in the pull request, which add TypeScript configuration (tsconfig.json) and update package.json to support TypeScript as the primary entry point.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
package.json (2)

25-31: ⚠️ Potential issue | 🔴 Critical

main entry point references non-existent TypeScript source; build not configured.

Line 25 points main to src/index.ts, but this file is not included in the files whitelist and Node.js cannot directly execute TypeScript. Additionally, the build script at line 34 is not configured ("build": "echo \"Build step not configured yet\""), so even the dist/ directory listed in files will not be generated. This will cause package resolution failures for all consumers.

Correct the entrypoint to reference the compiled output and configure the build process:

Suggested fix
   "main": "dist/index.js",
+  "types": "dist/index.d.ts",
   "files": [
     "dist",
-    "index.js",
     "README.md",
     "LICENSE"
   ],
   "scripts": {
     "test": "echo \"No tests specified\"",
-    "build": "echo \"Build step not configured yet\""
+    "build": "tsc"
   },
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@package.json` around lines 25 - 31, The package.json currently points "main"
to a TS source ("src/index.ts") and has a noop "build" script; change "main" to
the compiled entry (e.g., "dist/index.js"), update the "build" script to compile
TypeScript (for example "tsc -p tsconfig.json" or your project's build command)
so dist/ is generated, and add a publishing hook (e.g., "prepublishOnly": "npm
run build") if you want builds before publish; ensure the "files" array still
includes "dist" so the compiled output is packaged.

33-40: ⚠️ Potential issue | 🔴 Critical

Fix TypeScript compilation setup and entry point configuration.

The main entry point is configured to src/index.ts (TypeScript source), but the package must distribute compiled JavaScript. The build script is a placeholder, so compilation never occurs. When installed via npm, consumers will receive TypeScript source files instead of usable JavaScript.

Fixes required:

  1. Add actual TypeScript compilation to the build script
  2. Update main entry point to dist/index.js after compilation
  3. Add prepublishOnly hook to ensure dist/ is generated before publishing
Suggested updates
   "main": "src/index.ts",
+  "main": "dist/index.js",
   "scripts": {
     "test": "echo \"No tests specified\"",
-    "build": "echo \"Build step not configured yet\""
+    "build": "tsc",
+    "prepublishOnly": "npm run build"
   },
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@package.json` around lines 33 - 40, Update package.json so consumers get
compiled JS: replace the placeholder "build" script with a TypeScript compile
command (e.g., run tsc --project tsconfig.json outputting to dist), change the
"main" field from "src/index.ts" to "dist/index.js", and add a "prepublishOnly"
script that runs the "build" script to ensure dist/ is generated before
publishing; reference the existing "build" script, "main" entry, and add
"prepublishOnly" to guarantee compilation.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@tsconfig.json`:
- Around line 4-10: Update tsconfig.json to use NodeNext ESM resolution: change
the "moduleResolution" property from "Node" to "NodeNext" and also set the
"module" property to "NodeNext" (currently "ESNext") so TypeScript's module
resolution matches Node's ESM behavior; modify the "module" and
"moduleResolution" entries in tsconfig.json accordingly.

---

Outside diff comments:
In `@package.json`:
- Around line 25-31: The package.json currently points "main" to a TS source
("src/index.ts") and has a noop "build" script; change "main" to the compiled
entry (e.g., "dist/index.js"), update the "build" script to compile TypeScript
(for example "tsc -p tsconfig.json" or your project's build command) so dist/ is
generated, and add a publishing hook (e.g., "prepublishOnly": "npm run build")
if you want builds before publish; ensure the "files" array still includes
"dist" so the compiled output is packaged.
- Around line 33-40: Update package.json so consumers get compiled JS: replace
the placeholder "build" script with a TypeScript compile command (e.g., run tsc
--project tsconfig.json outputting to dist), change the "main" field from
"src/index.ts" to "dist/index.js", and add a "prepublishOnly" script that runs
the "build" script to ensure dist/ is generated before publishing; reference the
existing "build" script, "main" entry, and add "prepublishOnly" to guarantee
compilation.

ℹ️ Review info

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2ec5238 and e98fd1d.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (3)
  • package.json
  • src/index.ts
  • tsconfig.json

Comment on lines +4 to +10
"module": "ESNext",
"declaration": true,
"outDir": "dist",
"strict": true,
"jsx": "react-jsx",
"moduleResolution": "Node",
"esModuleInterop": true,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify current ESM/TS resolver alignment and detect extensionless relative imports.
fd -a "package.json" -x sh -c 'echo "== $1 =="; jq -r ".type, .main" "$1"' sh {} 2>/dev/null
fd -a "tsconfig.json" -x sh -c 'echo "== $1 =="; jq -r ".compilerOptions.module, .compilerOptions.moduleResolution" "$1"' sh {} 2>/dev/null
rg -nP --type=ts 'from\s+["'"'"'](\./|\.\./)[^"'"'"']+(?<!\.(js|mjs|cjs|ts|tsx))["'"'"']' 2>/dev/null

Repository: AOSSIE-Org/SupportUsButton

Length of output: 178


🏁 Script executed:

#!/bin/bash
# Find TypeScript/JavaScript files and check their import statements
echo "=== Finding TS/JS files ==="
fd -e ts -e tsx -e js -e jsx | head -20

echo ""
echo "=== Checking actual imports in source files ==="
fd -e ts -e tsx src | head -10 | xargs -I {} sh -c 'echo "File: {}"; head -30 "{}"'

echo ""
echo "=== Checking package.json for exports/main fields ==="
jq '.exports, .main, .type, .scripts' package.json 2>/dev/null

Repository: AOSSIE-Org/SupportUsButton

Length of output: 340


🏁 Script executed:

#!/bin/bash
# Read the actual content of src/index.ts
echo "=== Content of src/index.ts ==="
cat -n src/index.ts

echo ""
echo "=== Full tsconfig.json ==="
cat -n tsconfig.json

echo ""
echo "=== Full package.json ==="
cat -n package.json

Repository: AOSSIE-Org/SupportUsButton

Length of output: 1896


Use NodeNext module resolution for Node ESM compatibility.

With "type": "module" and "engines": {"node": ">=14"}, the current config ("module": "ESNext", "moduleResolution": "Node") can allow TypeScript to accept imports that fail at Node runtime. Align both to NodeNext for consistency between TypeScript resolution and Node ESM behavior.

Suggested config update
   "compilerOptions": {
     "target": "ES2020",
-    "module": "ESNext",
+    "module": "NodeNext",
     "declaration": true,
     "outDir": "dist",
     "strict": true,
     "jsx": "react-jsx",
-    "moduleResolution": "Node",
+    "moduleResolution": "NodeNext",
+    "verbatimModuleSyntax": true,
     "esModuleInterop": true,
     "skipLibCheck": true,
     "forceConsistentCasingInFileNames": true
   },
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"module": "ESNext",
"declaration": true,
"outDir": "dist",
"strict": true,
"jsx": "react-jsx",
"moduleResolution": "Node",
"esModuleInterop": true,
"module": "NodeNext",
"declaration": true,
"outDir": "dist",
"strict": true,
"jsx": "react-jsx",
"moduleResolution": "NodeNext",
"verbatimModuleSyntax": true,
"esModuleInterop": true,
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tsconfig.json` around lines 4 - 10, Update tsconfig.json to use NodeNext ESM
resolution: change the "moduleResolution" property from "Node" to "NodeNext" and
also set the "module" property to "NodeNext" (currently "ESNext") so
TypeScript's module resolution matches Node's ESM behavior; modify the "module"
and "moduleResolution" entries in tsconfig.json accordingly.

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

Labels

configuration Configuration file changes dependencies Dependency file changes javascript JavaScript/TypeScript code changes no-issue-linked PR is not linked to any issue pending-coderabbit-review repeat-contributor PR from an external contributor who already had PRs merged size/M Medium PR (51-200 lines changed)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant