Skip to content
This repository has been archived by the owner on Aug 4, 2021. It is now read-only.

Add index.d.ts typings file #138

Merged
merged 1 commit into from
Nov 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;