Skip to content

Commit

Permalink
pdfjs-dist expand exports, export pdfjs-dist from react-pdf (Definite…
Browse files Browse the repository at this point in the history
…lyTyped#38117)

* pdfjs-dist module definition

* Declare pdfjs export in react-pdf

* Remove react-pdf/package.json, fix-up default export

* Add pdfjs test to react-pdf
  • Loading branch information
nikuda authored and pheromonez committed Sep 17, 2019
1 parent e584998 commit cb157b1
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 6 deletions.
8 changes: 8 additions & 0 deletions types/pdfjs-dist/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@

/// <reference lib="dom"/>

declare const version: string;

declare const GlobalWorkerOptions: GlobalWorkerOptions;

interface GlobalWorkerOptions {
workerSrc: string;
}

interface PDFPromise<T> {
isResolved(): boolean;
isRejected(): boolean;
Expand Down
1 change: 1 addition & 0 deletions types/react-pdf/dist/entry.parcel.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export { default as Document } from './Document';
export { default as Page } from './Page';
export { default as Outline } from './Outline';
export { default as pdfjs } from './pdfjs-dist';
1 change: 1 addition & 0 deletions types/react-pdf/dist/entry.webpack.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export { default as Document } from './Document';
export { default as Page } from './Page';
export { default as Outline } from './Outline';
export { default as pdfjs } from './pdfjs-dist';
3 changes: 3 additions & 0 deletions types/react-pdf/dist/pdfjs-dist.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import * as pdfjs from 'pdfjs-dist';

export default pdfjs;
7 changes: 2 additions & 5 deletions types/react-pdf/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@
import Document from './dist/Document';
import Page from './dist/Page';
import Outline from './dist/Outline';
import pdfjs from './dist/pdfjs-dist';

export {
Document,
Page,
Outline
};
export { pdfjs, Document, Page, Outline };
4 changes: 3 additions & 1 deletion types/react-pdf/react-pdf-tests.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import * as React from 'react';
import { Document, Page } from 'react-pdf';
import { Document, Page, pdfjs } from 'react-pdf';
import { PDFDocumentProxy } from 'pdfjs-dist';

pdfjs.GlobalWorkerOptions.workerSrc = `//cdnjs.cloudflare.com/ajax/libs/pdf.js/${pdfjs.version}/pdf.worker.js`;

interface State {
numPages: number | null;
pageNumber: number;
Expand Down

0 comments on commit cb157b1

Please sign in to comment.