├── .eslintrc.js ├── .gitattributes ├── .github ├── ISSUE_TEMPLATE │ ├── 01-bug.md │ └── 02-feature.md └── workflows │ └── main.yml ├── .gitignore ├── .npmrc ├── .nvmrc ├── .prettierignore ├── .prettierrc ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE.md ├── PRACTICES.md ├── README.md ├── STANDARDS.ts ├── jest.config.ts ├── package.json ├── rollup.config.ts ├── src ├── add.ts ├── index.ts └── multiply.ts ├── test ├── add.test.ts ├── multiply.test.ts └── tsconfig.json ├── tsconfig.json └── yarn.lock /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, 3 | parser: '@typescript-eslint/parser', 4 | plugins: ['@typescript-eslint', 'jest', 'prettier'], 5 | extends: [ 6 | 'eslint:recommended', 7 | 'plugin:@typescript-eslint/recommended', 8 | 'plugin:prettier/recommended', 9 | 'prettier', 10 | ], 11 | rules: { 12 | 'jest/no-disabled-tests': 'warn', 13 | 'jest/no-focused-tests': 'error', 14 | 'jest/no-identical-title': 'error', 15 | }, 16 | } 17 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto eol=lf -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/01-bug.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: 'New issue' 3 | about: 'Let us know what you are struggling with' 4 | title: '' 5 | labels: bug 6 | --- 7 | 8 | ## Description 9 | 10 | 11 | 12 | ## Reproduction steps 13 | 14 | 15 | 16 | 17 | ## Expected behavior 18 | 19 | 20 | 21 | ## Initial assessment 22 | 23 | 24 | 25 | ## Screenshots 26 | 27 | 28 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/02-feature.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: 'New feature' 3 | about: 'Request or suggest a new feature' 4 | title: '' 5 | labels: feature 6 | --- 7 | 8 | ## Description 9 | 10 | 11 | 12 | 13 | ## Alternatives 14 | 15 | 16 | -------------------------------------------------------------------------------- /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: 4 | push: 5 | branches: [main] 6 | pull_request: 7 | branches: [main] 8 | 9 | workflow_dispatch: 10 | 11 | jobs: 12 | build: 13 | runs-on: ubuntu-latest 14 | steps: 15 | - name: Cancel previous runs 16 | uses: styfle/cancel-workflow-action@0.6.0 17 | with: 18 | access_token: ${{ secrets.GITHUB_TOKEN }} 19 | 20 | - name: Checkout repository 21 | uses: actions/checkout@v2 22 | 23 | - name: Install dependencies 24 | uses: bahmutov/npm-install@v1 25 | with: 26 | useLockFile: false 27 | 28 | - name: Build the library 29 | run: yarn build 30 | 31 | - name: Test the library 32 | run: yarn test 33 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | lerna-debug.log* 8 | 9 | # Diagnostic reports (https://nodejs.org/api/report.html) 10 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 11 | 12 | # Runtime data 13 | pids 14 | *.pid 15 | *.seed 16 | *.pid.lock 17 | 18 | # Directory for instrumented libs generated by jscoverage/JSCover 19 | lib-cov 20 | 21 | # Coverage directory used by tools like istanbul 22 | coverage 23 | *.lcov 24 | 25 | # nyc test coverage 26 | .nyc_output 27 | 28 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 29 | .grunt 30 | 31 | # Bower dependency directory (https://bower.io/) 32 | bower_components 33 | 34 | # node-waf configuration 35 | .lock-wscript 36 | 37 | # Compiled binary addons (https://nodejs.org/api/addons.html) 38 | build/Release 39 | 40 | # Dependency directories 41 | node_modules/ 42 | jspm_packages/ 43 | 44 | # TypeScript v1 declaration files 45 | typings/ 46 | 47 | # TypeScript cache 48 | *.tsbuildinfo 49 | 50 | # Optional npm cache directory 51 | .npm 52 | 53 | # Optional eslint cache 54 | .eslintcache 55 | 56 | # Microbundle cache 57 | .rpt2_cache/ 58 | .rts2_cache_cjs/ 59 | .rts2_cache_es/ 60 | .rts2_cache_umd/ 61 | 62 | # Optional REPL history 63 | .node_repl_history 64 | 65 | # Output of 'npm pack' 66 | *.tgz 67 | 68 | # Yarn Integrity file 69 | .yarn-integrity 70 | 71 | # dotenv environment variables file 72 | .env 73 | .env.test 74 | 75 | # parcel-bundler cache (https://parceljs.org/) 76 | .cache 77 | 78 | # Next.js build output 79 | .next 80 | 81 | # Nuxt.js build / generate output 82 | .nuxt 83 | dist 84 | 85 | # Gatsby files 86 | .cache/ 87 | # Comment in the public line in if your project uses Gatsby and *not* Next.js 88 | # https://nextjs.org/blog/next-9-1#public-directory-support 89 | # public 90 | 91 | # vuepress build output 92 | .vuepress/dist 93 | 94 | # Serverless directories 95 | .serverless/ 96 | 97 | # FuseBox cache 98 | .fusebox/ 99 | 100 | # DynamoDB Local files 101 | .dynamodb/ 102 | 103 | # TernJS port file 104 | .tern-port 105 | 106 | # OS files 107 | *.DS_Store 108 | 109 | # Build 110 | lib 111 | -------------------------------------------------------------------------------- /.npmrc: -------------------------------------------------------------------------------- 1 | package-lock=false -------------------------------------------------------------------------------- /.nvmrc: -------------------------------------------------------------------------------- 1 | v12.18.0 -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | lib -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "semi": false, 3 | "singleQuote": true, 4 | "trailingComma": "all", 5 | "arrowParens": "always", 6 | "useTabs": false, 7 | "tabWidth": 2 8 | } 9 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | We as members, contributors, and leaders pledge to make participation in our 6 | community a harassment-free experience for everyone, regardless of age, body 7 | size, visible or invisible disability, ethnicity, sex characteristics, gender 8 | identity and expression, level of experience, education, socio-economic status, 9 | nationality, personal appearance, race, religion, or sexual identity and 10 | orientation. 11 | 12 | We pledge to act and interact in ways that contribute to an open, welcoming, 13 | diverse, inclusive, and healthy community. 14 | 15 | ## Our Standards 16 | 17 | Examples of behavior that contributes to a positive environment for our 18 | community include: 19 | 20 | - Demonstrating empathy and kindness toward other people 21 | - Being respectful of differing opinions, viewpoints, and experiences 22 | - Giving and gracefully accepting constructive feedback 23 | - Accepting responsibility and apologizing to those affected by our mistakes, 24 | and learning from the experience 25 | - Focusing on what is best not just for us as individuals, but for the overall 26 | community 27 | 28 | Examples of unacceptable behavior include: 29 | 30 | - The use of sexualized language or imagery, and sexual attention or advances of 31 | any kind 32 | - Trolling, insulting or derogatory comments, and personal or political attacks 33 | - Public or private harassment 34 | - Publishing others' private information, such as a physical or email address, 35 | without their explicit permission 36 | - Other conduct which could reasonably be considered inappropriate in a 37 | professional setting 38 | 39 | ## Enforcement Responsibilities 40 | 41 | Community leaders are responsible for clarifying and enforcing our standards of 42 | acceptable behavior and will take appropriate and fair corrective action in 43 | response to any behavior that they deem inappropriate, threatening, offensive, 44 | or harmful. 45 | 46 | Community leaders have the right and responsibility to remove, edit, or reject 47 | comments, commits, code, wiki edits, issues, and other contributions that are 48 | not aligned to this Code of Conduct, and will communicate reasons for moderation 49 | decisions when appropriate. 50 | 51 | ## Scope 52 | 53 | This Code of Conduct applies within all community spaces, and also applies when 54 | an individual is officially representing the community in public spaces. 55 | Examples of representing our community include using an official e-mail address, 56 | posting via an official social media account, or acting as an appointed 57 | representative at an online or offline event. 58 | 59 | ## Enforcement 60 | 61 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 62 | reported to the community leaders responsible for enforcement. All complaints 63 | will be reviewed and investigated promptly and fairly. 64 | 65 | All community leaders are obligated to respect the privacy and security of the 66 | reporter of any incident. 67 | 68 | ## Enforcement Guidelines 69 | 70 | Community leaders will follow these Community Impact Guidelines in determining 71 | the consequences for any action they deem in violation of this Code of Conduct: 72 | 73 | ### 1. Correction 74 | 75 | **Community Impact**: Use of inappropriate language or other behavior deemed 76 | unprofessional or unwelcome in the community. 77 | 78 | **Consequence**: A private, written warning from community leaders, providing 79 | clarity around the nature of the violation and an explanation of why the 80 | behavior was inappropriate. A public apology may be requested. 81 | 82 | ### 2. Warning 83 | 84 | **Community Impact**: A violation through a single incident or series of 85 | actions. 86 | 87 | **Consequence**: A warning with consequences for continued behavior. No 88 | interaction with the people involved, including unsolicited interaction with 89 | those enforcing the Code of Conduct, for a specified period of time. This 90 | includes avoiding interactions in community spaces as well as external channels 91 | like social media. Violating these terms may lead to a temporary or permanent 92 | ban. 93 | 94 | ### 3. Temporary Ban 95 | 96 | **Community Impact**: A serious violation of community standards, including 97 | sustained inappropriate behavior. 98 | 99 | **Consequence**: A temporary ban from any sort of interaction or public 100 | communication with the community for a specified period of time. No public or 101 | private interaction with the people involved, including unsolicited interaction 102 | with those enforcing the Code of Conduct, is allowed during this period. 103 | Violating these terms may lead to a permanent ban. 104 | 105 | ### 4. Permanent Ban 106 | 107 | **Community Impact**: Demonstrating a pattern of violation of community 108 | standards, including sustained inappropriate behavior, harassment of an 109 | individual, or aggression toward or disparagement of classes of individuals. 110 | 111 | **Consequence**: A permanent ban from any sort of public interaction within the 112 | community. 113 | 114 | ## Attribution 115 | 116 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], 117 | version 2.0, available at 118 | https://www.contributor-covenant.org/version/2/0/code_of_conduct.html. 119 | 120 | Community Impact Guidelines were inspired by 121 | [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity). 122 | 123 | [homepage]: https://www.contributor-covenant.org 124 | 125 | For answers to common questions about this code of conduct, see the FAQ at 126 | https://www.contributor-covenant.org/faq. Translations are available at 127 | https://www.contributor-covenant.org/translations. 128 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | Thank you for considering contributing to this library! Below you can find the instructions on the development process, as well as testing and publishing guidelines. Don't hesitate to reach out to the library maintainers in the case of questions. 4 | 5 | ## Pre-requisites 6 | 7 | - [Yarn](https://classic.yarnpkg.com/) 8 | - [TypeScript](https://www.typescriptlang.org/) 9 | - [Jest](https://jestjs.io/) 10 | 11 | ## Git workflow 12 | 13 | ```bash 14 | $ git checkout -b 15 | $ git add . 16 | $ git commit -m 'Adds contribution guidelines' 17 | $ git push -u origin 18 | ``` 19 | 20 | Ensure that your feature branch is up-to-date with the latest `main` before assigning it for code review: 21 | 22 | ```bash 23 | $ git checkout master 24 | $ git pull --rebase 25 | $ git checkout 26 | $ git rebase master 27 | ``` 28 | 29 | Once your changes are ready, open a Pull request and assign one of the library maintainers as a reviewer. We will go through your changes and ensure they land in the next release. 30 | 31 | ## Develop 32 | 33 | ```bash 34 | $ yarn start 35 | ``` 36 | 37 | ## Test 38 | 39 | ### Run all tests 40 | 41 | ```bash 42 | $ yarn test 43 | ``` 44 | 45 | ### Run a single test 46 | 47 | ```bash 48 | $ yarn test test/add.test.ts 49 | ``` 50 | 51 | ## Publish 52 | 53 | Follow this instructions to publish the library: 54 | 55 | 1. Log in with your [NPM](http://npmjs.com/) account (verify your current user with `npm whoami`). 56 | 1. Run `yarn publish`. 57 | 1. Set the next version of the library. 58 | 1. Wait for the build to succeed. 59 | 1. Push the release commit and tag with `git push --follow-tags`. 60 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | Copyright (c) 2021 Artem Zakharchenko 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy 5 | of this software and associated documentation files (the "Software"), to deal 6 | in the Software without restriction, including without limitation the rights 7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the Software is 9 | furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in all 12 | copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | SOFTWARE. 21 | -------------------------------------------------------------------------------- /PRACTICES.md: -------------------------------------------------------------------------------- 1 | # Practices 2 | 3 | This template repository comes with a number of best practices set up and configured so you could focus on working on your next awesome library. Below you can find the full list of features provided by this template. 4 | 5 | ## Linting 6 | 7 | - Uses `eslint` recommended configuration with TypeScript. 8 | - Uses `eslint-plugin-jest` for linting test suites. 9 | 10 | ## Productivity 11 | 12 | - Comes with a pre-configured CI pipeline (GitHub Actions). 13 | - Lints all staged files for commit via `husky` and `lint-staged`, preventing statically checked mistakes to be committed in the first place. 14 | - Configured import aliases (`compilerOptions.paths`) for shorter modules references during development and testing. 15 | 16 | ## Community 17 | 18 | - Includes a README template. 19 | - Includes detailed Contributing guidelines. 20 | - Includes a basic set of issues templates (GitHub). 21 | 22 | ## Distribution 23 | 24 | - Distributes the library in three formats: UMD, ESM, CommonJS. 25 | - Configures the bundler for a tree-shackable output. 26 | - Configures the publishing pipeline (`publishOnly`). 27 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Library name 2 | 3 | > A short description about what your library is. 4 | 5 | ## Motivation 6 | 7 | > Elaborate on the reason behind this library: why may people need it? What issues does it solve? How is it different from the similar libraries? 8 | 9 | ## Getting started 10 | 11 | > Go through the steps necessary to install, configure, and use your library. 12 | 13 | ### Install 14 | 15 | ```bash 16 | $ npm install 17 | ``` 18 | 19 | ## Documentation 20 | 21 | > Reference the documentation website, or write the documentation straight in this README file. 22 | 23 | ## Contributing 24 | 25 | Please read the [Contribution guidelines](CONTRIBUTING.md) to start with your awesome contributions! 26 | -------------------------------------------------------------------------------- /STANDARDS.ts: -------------------------------------------------------------------------------- 1 | import * as fs from 'fs' 2 | import * as path from 'path' 3 | import * as packageJson from './package.json' 4 | 5 | describe('Distribution', () => { 6 | it('Name and description', () => { 7 | expect(packageJson).toHaveProperty('name') 8 | expect(packageJson).toHaveProperty('description') 9 | }) 10 | 11 | it('Main entry point', () => { 12 | expect(fs.existsSync(packageJson.main)).toBe(true) 13 | }) 14 | 15 | it('Type definitions', () => { 16 | expect(fs.existsSync(packageJson.types)).toBe(true) 17 | }) 18 | }) 19 | 20 | describe('Community', () => { 21 | it('README', () => { 22 | const filenames = ['README', 'README.md'] 23 | expect(filenames.some(fs.existsSync)).toBe(true) 24 | }) 25 | 26 | it('Code of conduct', () => { 27 | const filenames = ['CODE_OF_CONDUCT', 'CODE_OF_CONDUCT.md'] 28 | expect(filenames.some(fs.existsSync)).toBe(true) 29 | }) 30 | 31 | it('Contributing guidelines', () => { 32 | const filenames = ['CONTRIBUTING', 'CONTRIBUTING.md'] 33 | const locations = ['.', '.github'] 34 | 35 | expect( 36 | filenames.some((filename) => { 37 | return locations.some((location) => { 38 | return fs.existsSync(path.resolve(location, filename)) 39 | }) 40 | }), 41 | ) 42 | }) 43 | 44 | it('License', () => { 45 | expect(packageJson).toHaveProperty('license') 46 | 47 | const filenames = ['LICENSE', 'LICENSE.md'] 48 | expect(filenames.some(fs.existsSync)).toBe(true) 49 | }) 50 | }) 51 | -------------------------------------------------------------------------------- /jest.config.ts: -------------------------------------------------------------------------------- 1 | import { pathsToModuleNameMapper } from 'ts-jest/utils' 2 | import { compilerOptions } from './tsconfig.json' 3 | 4 | export default { 5 | preset: 'ts-jest', 6 | moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths, { 7 | prefix: '', 8 | }), 9 | } 10 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "create-typescript-library", 3 | "version": "0.0.0", 4 | "description": "A repository template for a TypeScript library.", 5 | "main": "lib/umd/index.js", 6 | "module": "lib/esm/index.js", 7 | "types": "lib/index.d.ts", 8 | "repository": "git@github.com:kettanaito/create-typescript-library.git", 9 | "author": "Artem Zakharchenko ", 10 | "license": "MIT", 11 | "scripts": { 12 | "start": "rollup -c rollup.config.ts -w", 13 | "lint": "eslint ./{src,test}/**/*.ts", 14 | "clean": "rimraf ./lib", 15 | "build": "yarn lint && yarn clean && rollup -c rollup.config.ts", 16 | "test": "jest test", 17 | "test:lib": "jest STANDARDS.ts --testRegex=\"(STANDARDS\\.ts)\"", 18 | "prepublishOnly": "yarn build && yarn test:lib && yarn test" 19 | }, 20 | "files": [ 21 | "lib", 22 | "README.md" 23 | ], 24 | "lint-staged": { 25 | "*.ts": [ 26 | "prettier --write", 27 | "eslint --fix" 28 | ] 29 | }, 30 | "husky": { 31 | "hooks": { 32 | "pre-commit": "lint-staged" 33 | } 34 | }, 35 | "engines": { 36 | "node": ">= 12.18.0" 37 | }, 38 | "devDependencies": { 39 | "@rollup/plugin-commonjs": "^17.1.0", 40 | "@rollup/plugin-json": "^4.1.0", 41 | "@rollup/plugin-node-resolve": "^11.1.1", 42 | "@types/jest": "^26.0.20", 43 | "@typescript-eslint/eslint-plugin": "^4.14.2", 44 | "@typescript-eslint/parser": "^4.14.2", 45 | "eslint": "^7.19.0", 46 | "eslint-config-prettier": "^7.2.0", 47 | "eslint-plugin-jest": "^24.1.3", 48 | "eslint-plugin-prettier": "^3.3.1", 49 | "husky": "^4.3.8", 50 | "jest": "^26.6.3", 51 | "lint-staged": "^10.5.3", 52 | "prettier": "^2.2.1", 53 | "rimraf": "^3.0.2", 54 | "rollup": "^2.38.4", 55 | "rollup-plugin-typescript2": "^0.29.0", 56 | "ts-jest": "^26.5.0", 57 | "ts-node": "^9.1.1", 58 | "typescript": "^4.1.3" 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /rollup.config.ts: -------------------------------------------------------------------------------- 1 | import * as path from 'path' 2 | import resolve from '@rollup/plugin-node-resolve' 3 | import commonjs from '@rollup/plugin-commonjs' 4 | import json from '@rollup/plugin-json' 5 | import typescript from 'rollup-plugin-typescript2' 6 | import packageJson from './package.json' 7 | 8 | const plugins = [ 9 | json(), 10 | resolve({ 11 | mainFields: ['module', 'main', 'jsnext:main', 'browser'], 12 | extensions: ['.js', '.jsx', '.ts', '.tsx'], 13 | }), 14 | typescript({ 15 | // Emit declarations in the specified directory 16 | // instead of next to each individual built target. 17 | useTsconfigDeclarationDir: true, 18 | }), 19 | commonjs(), 20 | ] 21 | 22 | const buildEsm = { 23 | input: [ 24 | 'src/index.ts', 25 | // List non-dependent modules so they could be tree-shaken 26 | // by the library's consumer. 27 | 'src/add.ts', 28 | 'src/multiply.ts', 29 | ], 30 | output: { 31 | format: 'esm', 32 | entryFileNames: '[name].js', 33 | chunkFileNames: '[name]-deps.js', 34 | dir: path.dirname(packageJson.module), 35 | }, 36 | plugins, 37 | } 38 | 39 | const buildUmd = { 40 | input: 'src/index.ts', 41 | output: { 42 | format: 'umd', 43 | esModule: false, 44 | file: packageJson.main, 45 | name: packageJson.name.replace(/(?:^|-)(\w)/g, (_, letter) => 46 | letter.toUpperCase() 47 | ), 48 | }, 49 | plugins, 50 | } 51 | 52 | const buildCjs = { 53 | input: 'src/index.ts', 54 | output: { 55 | format: 'cjs', 56 | file: path.resolve(path.dirname(packageJson.types), 'cjs/index.js'), 57 | }, 58 | plugins, 59 | } 60 | 61 | export default [buildEsm, buildUmd, buildCjs] 62 | -------------------------------------------------------------------------------- /src/add.ts: -------------------------------------------------------------------------------- 1 | export function add(first: number, second: number): number { 2 | return first + second 3 | } 4 | -------------------------------------------------------------------------------- /src/index.ts: -------------------------------------------------------------------------------- 1 | export { add } from './add' 2 | export { multiply } from './multiply' 3 | -------------------------------------------------------------------------------- /src/multiply.ts: -------------------------------------------------------------------------------- 1 | export function multiply(first: number, second: number): number { 2 | return first * second 3 | } 4 | -------------------------------------------------------------------------------- /test/add.test.ts: -------------------------------------------------------------------------------- 1 | import { add } from 'src/add' 2 | 3 | it('adds two given numbers', () => { 4 | expect(add(2, 5)).toBe(7) 5 | }) 6 | -------------------------------------------------------------------------------- /test/multiply.test.ts: -------------------------------------------------------------------------------- 1 | import { multiply } from 'src/multiply' 2 | 3 | it('multiplies two given numbers', () => { 4 | expect(multiply(3, 2)).toBe(6) 5 | }) 6 | -------------------------------------------------------------------------------- /test/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "noEmit": true 5 | }, 6 | "include": ["**/*.test.ts"] 7 | } 8 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "strict": true, 4 | "allowJs": false, 5 | "moduleResolution": "node", 6 | "allowSyntheticDefaultImports": false, 7 | "forceConsistentCasingInFileNames": true, 8 | "resolveJsonModule": true, 9 | "noImplicitAny": true, 10 | "outDir": "lib", 11 | "declaration": true, 12 | "declarationDir": "lib", 13 | "baseUrl": "./", 14 | "paths": { 15 | "src/*": ["src/*"] 16 | } 17 | }, 18 | "include": ["src/**/*.ts"], 19 | "exclude": ["node_modules"] 20 | } 21 | --------------------------------------------------------------------------------