Make your npm package conformable to TypeScript

Change your index.js file to index.ts

Initialize with tsc command

$ tsc --init
message TS6071: Successfully created a tsconfig.json file.

Add "declaration": true to your tsconfig.json

{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"declaration": true,
"strict": true,
"esModuleInterop": true
},
"exclude": [
"node_modules",
"dist"
]
}

Add "types": "index.d.ts" to your package.json

{
"name": "@taishikato/slug-generator",
"version": "2.2.0",
"description": "generate slug string",
"main": "index.js",
"types": "index.d.ts",
"repository": "https://github.com/taishikato/slug-generator",
"author": "taishikato",
"license": "MIT",
"private": false,
"scripts": {
"build": "tsc"
},
"dependencies": {
"uuid": "^7.0.2"
},
"keywords": [
"slug",
"npm",
"package",
"taishikato",
"slug generator"
],
"devDependencies": {
"@types/uuid": "^7.0.2",
"typescript": "^3.8.3"
}
}

Add .npmignore

.gitignore
yarn.lock
node_modules
index.ts

taishikato/slug-generator: Slug generator for blog posts or any other user-generated-contents

Portfolio

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store