Skip to content

Commit cf98a87

Browse files
committed
Fix TypeScript errors
1 parent 34a1093 commit cf98a87

File tree

3 files changed

+23
-17
lines changed

3 files changed

+23
-17
lines changed

src/index.ts

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,14 @@ import babelPresetEnv from '@babel/preset-env';
66
import babelPresetTypescript from '@babel/preset-typescript';
77
import builtinModules from 'builtin-modules';
88
import { outputFile, readFile } from 'fs-extra';
9-
import { rollup, watch, OutputOptions, InputOptions } from 'rollup';
9+
import {
10+
rollup,
11+
watch,
12+
OutputOptions,
13+
InputOptions,
14+
RollupWarning,
15+
RollupWatchOptions,
16+
} from 'rollup';
1017
import babel from 'rollup-plugin-babel';
1118
import commonjs from 'rollup-plugin-commonjs';
1219
import dts from 'rollup-plugin-dts';
@@ -126,7 +133,7 @@ async function createRollupConfig({
126133
return { inputOptions, outputOptions };
127134
}
128135

129-
function dtsOnWarn(warning: { code: string; message: string }) {
136+
function dtsOnWarn(warning: RollupWarning) {
130137
if (warning.code === 'EMPTY_BUNDLE') return;
131138

132139
console.error(warning.message);
@@ -140,7 +147,7 @@ async function createTypes({
140147
outputDir: string;
141148
}) {
142149
// build our Rollup input options for rollup-plugin-dts
143-
const inputOptions = {
150+
const inputOptions: InputOptions = {
144151
input,
145152
plugins: [dts()],
146153
onwarn: dtsOnWarn,
@@ -153,7 +160,7 @@ async function createTypes({
153160
const { name } = parse(input);
154161

155162
// build our Rollup output options
156-
const outputOptions = {
163+
const outputOptions: OutputOptions = {
157164
file: resolve(outputDir, format({ name, ext: '.d.ts' })),
158165
format: 'esm',
159166
};
@@ -234,7 +241,7 @@ export async function bundler({
234241

235242
for (const { inputOptions, outputOptions } of runs) {
236243
if (watchBuild) {
237-
const watcher = watch(
244+
const watchOptions: RollupWatchOptions[] = [
238245
Object.assign(
239246
{
240247
output: outputOptions,
@@ -243,16 +250,15 @@ export async function bundler({
243250
},
244251
},
245252
inputOptions
246-
)
247-
);
253+
),
254+
];
255+
256+
const watcher = watch(watchOptions);
248257

249-
watcher.on('event', ({ code, error }) => {
250-
switch (code) {
251-
case 'FATAL':
252-
throw new Error(error);
258+
watcher.on('event', event => {
259+
switch (event.code) {
253260
case 'ERROR':
254-
console.error(error);
255-
break;
261+
throw event.error;
256262
case 'END':
257263
console.log(`Successful build. (${inputOptions.input})`);
258264
break;

src/vendor.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
declare module '@babel/preset-env';
2+
declare module '@babel/preset-typescript';
3+
declare module 'rollup-plugin-babel';
4+
declare module 'rollup-plugin-json';

tsconfig.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@
44
"target": "esnext",
55
// Search under node_modules for non-relative imports.
66
"moduleResolution": "node",
7-
// Process & infer types from .js files.
8-
"allowJs": true,
9-
// Don't emit; allow Babel to transform files.
10-
"noEmit": true,
117
// Enable strictest settings like strictNullChecks & noImplicitAny.
128
"strict": true,
139
// Disallow features that require cross-file information for emit.

0 commit comments

Comments
 (0)