diff --git a/README.md b/README.md index c2ef43e9c..83ba1feef 100644 --- a/README.md +++ b/README.md @@ -319,32 +319,7 @@ module.exports = { }; ``` -The `options` object contains the following: - -```tsx -export interface TsdxOptions { - // path to file - input: string; - // Name of package - name: string; - // JS target - target: 'node' | 'browser'; - // Module format - format: 'cjs' | 'umd' | 'esm' | 'system'; - // Environment - env: 'development' | 'production'; - // Path to tsconfig file - tsconfig?: string; - // Is error extraction running? - extractErrors?: boolean; - // Is minifying? - minify?: boolean; - // Is this the very first rollup config (and thus should one-off metadata be extracted)? - writeMeta?: boolean; - // Only transpile, do not type check (makes compilation faster) - transpileOnly?: boolean; -} -``` +The `options` object type definition in [src/externalTypes.ts](src/externalTypes.ts). #### Example: Adding Postcss @@ -354,6 +329,10 @@ const autoprefixer = require('autoprefixer'); const cssnano = require('cssnano'); module.exports = { + /** + * @param {import('tsdx').RollupOptions} config + * @param {import('tsdx').TsdxOptions} options + */ rollup(config, options) { config.plugins.push( postcss({ diff --git a/package.json b/package.json index 049a344ef..b9e6ee737 100644 --- a/package.json +++ b/package.json @@ -18,6 +18,7 @@ "bugs": { "url": "https://github.com/formium/tsdx/issues" }, + "typings": "./dist/externalTypes.d.ts", "bin": { "tsdx": "./dist/index.js" }, diff --git a/src/externalTypes.ts b/src/externalTypes.ts new file mode 100644 index 000000000..5cbd5caf5 --- /dev/null +++ b/src/externalTypes.ts @@ -0,0 +1,2 @@ +export { RollupOptions } from 'rollup'; +export { TsdxOptions } from './types'; diff --git a/src/types.ts b/src/types.ts index e6878897e..600eeb331 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,9 +1,9 @@ interface SharedOpts { - // JS target + /** JS target */ target: 'node' | 'browser'; - // Path to tsconfig file + /** Path to tsconfig file */ tsconfig?: string; - // Is error extraction running? + /** Is error extraction running? */ extractErrors?: boolean; } @@ -33,19 +33,19 @@ export interface NormalizedOpts } export interface TsdxOptions extends SharedOpts { - // Name of package + /** Name of package */ name: string; - // path to file + /** path to file */ input: string; - // Environment + /** Environment */ env: 'development' | 'production'; - // Module format + /** Module format */ format: ModuleFormat; - // Is minifying? + /** Is minifying? */ minify?: boolean; - // Is this the very first rollup config (and thus should one-off metadata be extracted)? + /** Is this the very first rollup config (and thus should one-off metadata be extracted)? */ writeMeta?: boolean; - // Only transpile, do not type check (makes compilation faster) + /** Only transpile, do not type check (makes compilation faster) */ transpileOnly?: boolean; } diff --git a/test/integration/fixtures/build-withConfig/tsdx.config.js b/test/integration/fixtures/build-withConfig/tsdx.config.js index ba3c055ed..7cd3fdaa3 100644 --- a/test/integration/fixtures/build-withConfig/tsdx.config.js +++ b/test/integration/fixtures/build-withConfig/tsdx.config.js @@ -3,6 +3,10 @@ const autoprefixer = require('autoprefixer'); const cssnano = require('cssnano'); module.exports = { + /** + * @param {import('tsdx').RollupOptions} config + * @param {import('tsdx').TsdxOptions} options + */ rollup(config, options) { config.plugins.push( postcss({ diff --git a/tsconfig.json b/tsconfig.json index b1e42b698..fa022b806 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -7,7 +7,7 @@ "importHelpers": true, "esModuleInterop": true, "outDir": "dist", - "declaration": false, + "declaration": true, "module": "commonjs", "rootDir": "src", "strict": true,