1.1.0 • Published 3 years ago

typescript-library-for-hw v1.1.0

Weekly downloads
-
License
ISC
Repository
-
Last release
3 years ago

Notice the tsconfig.json file here

{
  "compilerOptions": {
    "module": "commonjs",
    "target": "es2015",
    "declaration": true,
    "outDir": "./dist"
  },
  "include": [
    "src/**/*"
  ]
}

The "declaration": true flag. This will generate the .d.ts files (aka declaration files) which contain the types of your code. This way, if someone is using your library and they also use TypeScript, they get the benefits of typesafety and autocomplete!

create a index.ts file in the src folder

export {sayHello, sayGoodbye} from './hello-world'

this will export the funtions from your library

And the consumers can use this library by

import {sayHello} from 'hwrld'
sayHello();

https://zellwk.com/blog/publish-to-npm/