Skip to content

Commit

Permalink
Add index.d.ts (rollup#138)
Browse files Browse the repository at this point in the history
  • Loading branch information
NotWoods authored and shellscape committed Nov 24, 2019
1 parent 38bce40 commit 30079e8
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 2 deletions.
45 changes: 45 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { Plugin } from 'rollup';
import { CompilerOptionsValue, TsConfigSourceFile } from 'typescript';

interface RollupTypescriptOptions {
/**
* Determine which files are transpiled by Typescript (all `.ts` and
* `.tsx` files by default).
*/
include?: string | RegExp | ReadonlyArray<string | RegExp> | null;
/**
* Determine which files are transpiled by Typescript (all `.ts` and
* `.tsx` files by default).
*/
exclude?: string | RegExp | ReadonlyArray<string | RegExp> | null;
/**
* When set to false, ignores any options specified in the config file.
* If set to a string that corresponds to a file path, the specified file
* will be used as config file.
*/
tsconfig?: string | false;
/**
* Overrides TypeScript used for transpilation
*/
typescript?: typeof import('typescript');
/**
* Overrides the injected TypeScript helpers with a custom version
*/
tslib?: typeof import('tslib');

/**
* Other Typescript compiler options
*/
[option: string]:
| CompilerOptionsValue
| TsConfigSourceFile
| RollupTypescriptOptions['include']
| RollupTypescriptOptions['typescript']
| RollupTypescriptOptions['tslib']
| undefined;
}

/**
* Seamless integration between Rollup and Typescript.
*/
export default function typescript(options?: RollupTypescriptOptions): Plugin;
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"jsnext:main": "dist/rollup-plugin-typescript.es.js",
"files": [
"dist",
"src"
"src",
"index.d.ts"
],
"keywords": [
"rollup-plugin",
Expand All @@ -22,7 +23,7 @@
"build": "rollup -c",
"lint": "eslint src test/*.js",
"pretest": "npm run build",
"test": "mocha",
"test": "mocha && tsc",
"posttest": "npm run lint",
"prepublishOnly": "npm run test",
"prepare": "npm run build"
Expand Down
16 changes: 16 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"compilerOptions": {
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strict": true,
"noEmit": true,
"allowJs": true
},
"files": [
"index.d.ts",
"typings-test.js"
]
}
21 changes: 21 additions & 0 deletions typings-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// @ts-check
import typescript from '.';

/** @type {import("rollup").RollupOptions} */
const config = {
input: 'main.js',
output: {
file: 'bundle.js',
format: 'iife'
},
plugins: [
typescript({
lib: ["es5", "es6", "dom"],
target: "es5",
include: 'node_modules/**',
exclude: ['node_modules/foo/**', 'node_modules/bar/**', /node_modules/],
})
]
};

export default config;

0 comments on commit 30079e8

Please sign in to comment.