Skip to content

Comments

feat: added typescript types for exported functions#1

Open
joshuagemvicente wants to merge 1 commit intosheldonix:mainfrom
joshuagemvicente:joshuagemvicente/feat/add-ts-types-for-exports
Open

feat: added typescript types for exported functions#1
joshuagemvicente wants to merge 1 commit intosheldonix:mainfrom
joshuagemvicente:joshuagemvicente/feat/add-ts-types-for-exports

Conversation

@joshuagemvicente
Copy link

Title: Add TypeScript support to cube-scramble package

Problem Description

The cube-scramble package lacks TypeScript type definitions, making it difficult to use in TypeScript projects without manual type declarations. Users who want type safety and IntelliSense support in their TypeScript applications currently have to write their own type definitions.

Steps to Reproduce

  1. Install the package: npm install cube-scramble
  2. Create a TypeScript file and try to import:
    import { getScramble } from 'cube-scramble';
    const scramble = getScramble('333');
    3. Observe that no type definitions are loaded
  3. Try to get IntelliSense/autocomplete - it won't work

Expected Behavior

The package should include:

  • Type definitions file (index.d.ts) with all exported functions
  • Proper types field in package.json
  • Full TypeScript support with IntelliSense
  • Type-safe parameter validation for puzzle types
  • Compile-time error detection for invalid puzzle types

Environment Details

  • OS: macOS (Tahoe 26.1)
  • Node.js Version: v22.20.0
  • npm Version: 10.9.3
  • TypeScript Version: Version 5.9.3
  • Package Version: 0.1.7

Proposed Solution
Add TypeScript support by:

  1. Creating index.d.ts with type definitions for all exports
  2. Adding "types": "./index.d.ts" to package.json
  3. Including comprehensive ScrambleType union type for all 20+ puzzle types

Copilot AI review requested due to automatic review settings January 28, 2026 16:02
@joshuagemvicente joshuagemvicente marked this pull request as draft January 28, 2026 16:03
@joshuagemvicente joshuagemvicente marked this pull request as ready for review January 28, 2026 16:03
@joshuagemvicente
Copy link
Author

Sorry, I can’t add labels or assignees on my end.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds TypeScript type definitions and package metadata so cube-scramble can be consumed with typings in TypeScript projects.

Changes:

  • Adds a root index.d.ts with exported API typings.
  • Updates package.json to advertise the types via types and exports.types.
  • Introduces TypeScript/tsup config artifacts and updates lockfile metadata.

Reviewed changes

Copilot reviewed 3 out of 9 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
index.d.ts New TypeScript declarations for exported functions and ScrambleType.
package.json Adds types + exports.types entries for TS resolution.
package-lock.json Lockfile metadata updates.
tsconfig.json Adds TS compiler configuration.
tsup.config.ts Formatting-only config update.
tsup.config.js Added compiled JS version of tsup config.
tsup.config.js.map Source map for compiled tsup config.
tsup.config.d.ts Generated declaration for tsup config.
tsup.config.d.ts.map Source map for generated tsup config declaration.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 8 to 16
"exports": {
".": {
"types": "./index.d.ts",
"import": "./dist/index.js",
"require": "./dist/index.cjs"
}
},
"types": "./index.d.ts",
"scripts": {
Copy link

Copilot AI Jan 28, 2026

Choose a reason for hiding this comment

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

package.json declares types: "./index.d.ts", but the files allowlist only includes dist, so index.d.ts will not be published to npm and consumers will still see missing types. Add index.d.ts (and any referenced .d.ts.map if you intend to ship it) to the files array, or remove the files allowlist so the types file is included in the published package.

Copilot uses AI. Check for mistakes.
Comment on lines +12 to +13
});
//# sourceMappingURL=tsup.config.js.map No newline at end of file
Copy link

Copilot AI Jan 28, 2026

Choose a reason for hiding this comment

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

tsup.config.js (and its sourcemap) appears to be a compiled output of tsup.config.ts (note the //# sourceMappingURL=...). Keeping both .ts and generated .js configs in source control risks them drifting out of sync. Prefer committing only the source config (tsup.config.ts) and ignore/remove generated .js/.map outputs (or switch to a single .js config if you don’t want TS here).

Suggested change
});
//# sourceMappingURL=tsup.config.js.map
});

Copilot uses AI. Check for mistakes.
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.

1 participant