cyc-type-def
v5.0.1
Published
Run these commands to use the package:
Downloads
152
Readme
Usage
Run these commands to use the package:
npm run build
npm publish --access publicTypeScript Package Setup Guide
This guide outlines how to set up a simple TypeScript package with build and test scripts.
1. Initialize Your Package
npm init -y2. Install TypeScript and Essential Dependencies
npm install typescript @types/node tsup --save-dev3. Set Up TypeScript Configuration
npx tsc --init4. Create Package Structure
my-ts-package/
├── src/
│ ├── index.ts # Main exports
│ ├── utils.ts # Utility functions
│ └── types.ts # Type definitions
├── test/ # Tests
├── dist/ # Compiled output
├── package.json
└── tsconfig.json5. Example Package Code
src/index.ts
export * from './utils';
export * from './types';src/utils.ts
export function greet(name: string): string {
return `Hello, ${name}!`;
}
export function sum(a: number, b: number): number {
return a + b;
}src/types.ts
export interface User {
id: string;
name: string;
email: string;
}6. package.json Scripts
"scripts": {
"build": "tsup src/index.ts --format cjs,esm --dts",
"dev": "tsup src/index.ts --format cjs,esm --dts --watch",
"test": "jest",
"prepublishOnly": "npm run build"
}