Skip to content

Enable strict type checking and fix types #420

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
2 changes: 0 additions & 2 deletions lib/annotations/AnnotationModels.js
Original file line number Diff line number Diff line change
Expand Up @@ -318,8 +318,6 @@ var BaseAnnotation = /** @class */ (function () {
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
/** Opacity value between 0 and 1 */
this.opacity = 1;
/** PDF object identifier */
this.pdfObjectId = null;
/** Version number */
this.v = 1;
/** Blend mode */
Expand Down
18 changes: 0 additions & 18 deletions lib/configuration/AIAssistantConfiguration.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,2 @@
"use strict";
/**
* @typedef AIAssistantConfiguration
* @memberof AIAssistantConfiguration
* @property { string } jwt The JSON Web Token used for authentication with your instance of the Nutrient AI Assistant server.
* @property { string } serverUrl Base HTTP URL where your instance of the Nutrient AI Assistant server can be reached.
* @property { string } sessionID A unique identifier for the chat session, which can be used to recall a session in the future.
* @property { string } [userID] An optional user identifier to associate with the session. This will be used to tag session history for user management.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.AIAssistantConfiguration = void 0;
/**
* @class AIAssistantConfiguration
*/
var AIAssistantConfiguration = /** @class */ (function () {
function AIAssistantConfiguration() {
}
return AIAssistantConfiguration;
}());
exports.AIAssistantConfiguration = AIAssistantConfiguration;
16 changes: 0 additions & 16 deletions lib/document/Bookmark.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,2 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Bookmark = void 0;
/**
* A Bookmark is a named location in a document.
* @interface Bookmark
* @memberof Bookmark
* @property {string} [name] - The bookmark name. This is optional.
* @property {string} displayName - The bookmark display name.
* @property {string} identifier - A string uniquely identifying the bookmark.
* @property {number} pageIndex - The page index on which the bookmark is located.
*/
var Bookmark = /** @class */ (function () {
function Bookmark() {
}
return Bookmark;
}());
exports.Bookmark = Bookmark;
10 changes: 1 addition & 9 deletions lib/document/PDFPageInfo.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.PDFPageInfo = void 0;
/**
* @interface PDFPageInfo
*/
var PDFPageInfo = /** @class */ (function () {
function PDFPageInfo() {
}
return PDFPageInfo;
}());
exports.PDFPageInfo = PDFPageInfo;
var PDFPageInfo;
(function (PDFPageInfo) {
/**
* The rotation of the page.
Expand Down
11 changes: 6 additions & 5 deletions lib/forms/FormElement.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,21 +70,22 @@ exports.TextFieldFormElement = exports.SignatureFormElement = exports.ChoiceForm
var FormElement = /** @class */ (function () {
function FormElement(data) {
if (data === void 0) { data = {}; }
var _a, _b, _c, _d, _e;
this.formField = data.formField;
this.resettable = data.resettable;
this.defaultValue = data.defaultValue;
this.exportValue = data.exportValue;
this.highlightColor = data.highlightColor;
this.calculationOrderIndex = data.calculationOrderIndex;
this.readOnly = data.readOnly;
this.required = data.required;
this.noExport = data.noExport;
this.readOnly = (_a = data.readOnly) !== null && _a !== void 0 ? _a : false;
this.required = (_b = data.required) !== null && _b !== void 0 ? _b : false;
this.noExport = (_c = data.noExport) !== null && _c !== void 0 ? _c : false;
this.fieldName = data.fieldName;
this.fullyQualifiedFieldName = data.fullyQualifiedFieldName;
this.formTypeName = data.formTypeName;
this.maxLength = data.maxLength;
this.doNotScroll = data.doNotScroll;
this.isMultiline = data.isMultiline;
this.doNotScroll = (_d = data.doNotScroll) !== null && _d !== void 0 ? _d : false;
this.isMultiline = (_e = data.isMultiline) !== null && _e !== void 0 ? _e : false;
}
return FormElement;
}());
Expand Down
29 changes: 1 addition & 28 deletions lib/measurements/Measurements.js
Original file line number Diff line number Diff line change
@@ -1,34 +1,7 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Measurements = void 0;
/**
* Measurement value configurations define how measurements are displayed and interpreted.
* @typedef MeasurementValueConfiguration
* @memberof Measurements
* @property {Measurements.MeasurementScale} scale - A ratio of a distance on a document page to a corresponding real world distance.
* @property {Measurements.Precision} precision - The smallest value to which measurements will be rounded.
* @property {string} [name] - Names are displayed in user interface and serve to help distinguish different scales.
* @property {boolean} [addToUndo] - Whether this new measurement configuration should be added to the undo stack (Android only).
* @property {boolean} [isSelected] - Whether this new measurement configuration should be set as selected on the UI.
*/
/**
* A ratio of a distance on a document page to a corresponding real world distance.
* @typedef MeasurementScale
* @memberof Measurements
* @property {Measurements.ScaleUnitFrom} unitFrom - The unit for the distance on a document page.
* @property {number} valueFrom - A distance on a document page. The unit of this value is given by ```unitFrom```.
* @property {Measurements.ScaleUnitTo} unitTo - The unit for the real world distance.
* @property {number} valueTo - A real world distance. The unit of this value is given by ```unitTo```.
*/
/**
* @interface Measurements
*/
var Measurements = /** @class */ (function () {
function Measurements() {
}
return Measurements;
}());
exports.Measurements = Measurements;
var Measurements;
(function (Measurements) {
/**
* The MeasurementScale UnitFrom options.
Expand Down
31 changes: 1 addition & 30 deletions lib/toolbar/Toolbar.js
Original file line number Diff line number Diff line change
@@ -1,36 +1,7 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Toolbar = void 0;
/**
* A toolbar item used to display a custom button on the toolbar.
* @typedef ToolbarItem
* @memberof Toolbar
* @property {string} id - The unique identifier for the custom toolbar button. This will be used to identify the button in the ```onCustomToolbarButtonTapped``` callback. On Android the ID needs to be specified as a resource item inside your application's ```ids.xml``` file.
* @property {string} image - The image name (iOS) or resource ID (Android) for the toolbar button. Images must be included in the application bundle on iOS and specified as a drawable resource on Android.
* @property {string} [title] - The title of the toolbar button (Android only).
* @property {boolean} [showAsAction] - Whether the toolbar button should be displayed on the main toolbar, and not in the drop down menu (Android only).
* @property {boolean} [applyTemplate] - Whether the icon should be rendered using the system's tint color to match the color scheme of other toolbar buttons. Set this to false if your icon already contains color information that should be preserved.
*/
/**
* The toolbar buttons that should be displayed on the toolbar.
* @typedef ToolbarItems
* @memberof Toolbar
* @property {Array<string | Toolbar.ToolbarItem>} buttons - An array of buttons that should be displayed on the toolbar. The buttons can be either stock toolbar buttons, custom toolbar buttons, or a combination of both.
* @property {string} [viewMode] - The viewMode for which the toolbar buttons should be set (iOS only).
* @property {string} [animated] - Whether the toolbar button change should be animated when they are set (iOS only).
*/
/**
* @interface Toolbar
* @property { Toolbar.ToolbarItems } [leftBarButtonItems] The bar buttons to display on the left side of the navigation bar (iOS only).
* @property { Toolbar.ToolbarItems } [rightBarButtonItems] The bar buttons to display on the right side of the navigation bar (iOS only).
* @property { Toolbar.ToolbarItems } [toolbarMenuItems] The toolbar buttons to display on the toolbar (Android only).
*/
var Toolbar = /** @class */ (function () {
function Toolbar() {
}
return Toolbar;
}());
exports.Toolbar = Toolbar;
var Toolbar;
(function (Toolbar) {
/**
* The stock toolbar buttons available to display on the Nutrient toolbar.
Expand Down
8 changes: 4 additions & 4 deletions src/annotations/AnnotationModels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -326,9 +326,9 @@ export class BaseAnnotation {
/** Opacity value between 0 and 1 */
opacity: number = 1;
/** PDF object identifier */
pdfObjectId?: number = null;
pdfObjectId?: number;
/** Annotation type */
type: string;
type?: string;
/** Annotation flags */
flags?: Array<string>;
/** Version number */
Expand Down Expand Up @@ -919,7 +919,7 @@ export class NoteAnnotation extends BaseAnnotation {
flags?: Array<string>;
customData?: Object;
color?: string;
icon?: 'comment' | 'rightPointer' | 'rightArrow' | 'check' | 'circle' | 'cross' |
icon?: 'comment' | 'rightPointer' | 'rightArrow' | 'check' | 'circle' | 'cross' |
'insert' | 'newParagraph' | 'note' | 'paragraph' | 'help' | 'star' | 'key';
text?: string | { format: string; value: string; };
}) {
Expand Down Expand Up @@ -1580,4 +1580,4 @@ export type AnnotationType =
| StrikeOutMarkupAnnotation
| TextAnnotation
| UnderlineMarkupAnnotation
| WidgetAnnotation;
| WidgetAnnotation;
10 changes: 3 additions & 7 deletions src/configuration/AIAssistantConfiguration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,11 @@
* @typedef AIAssistantConfiguration
* @memberof AIAssistantConfiguration
* @property { string } jwt The JSON Web Token used for authentication with your instance of the Nutrient AI Assistant server.
* @property { string } serverUrl Base HTTP URL where your instance of the Nutrient AI Assistant server can be reached.
* @property { string } serverURL Base HTTP URL where your instance of the Nutrient AI Assistant server can be reached.
* @property { string } sessionID A unique identifier for the chat session, which can be used to recall a session in the future.
* @property { string } [userID] An optional user identifier to associate with the session. This will be used to tag session history for user management.
*/

/**
* @class AIAssistantConfiguration
*/
export class AIAssistantConfiguration {
export interface AIAssistantConfiguration {
/**
* The JSON Web Token used for authentication with your instance of the Nutrient AI Assistant server.
*/
Expand All @@ -27,4 +23,4 @@ export class AIAssistantConfiguration {
* An optional user identifier to associate with the session. This will be used to tag session history for user management.
*/
userID?: string;
}
}
4 changes: 2 additions & 2 deletions src/document/Bookmark.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @property {string} identifier - A string uniquely identifying the bookmark.
* @property {number} pageIndex - The page index on which the bookmark is located.
*/
export class Bookmark {
export interface Bookmark {
/**
* The bookmark name. This is optional.
*/
Expand All @@ -24,4 +24,4 @@ export class Bookmark {
* The page index on which the bookmark is located.
*/
pageIndex: number;
}
}
4 changes: 2 additions & 2 deletions src/document/PDFPageInfo.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @interface PDFPageInfo
*/
export class PDFPageInfo {
export interface PDFPageInfo {
/**
* The angle the PDF page is displayed at in clockwise degrees.
*/
Expand Down Expand Up @@ -35,4 +35,4 @@ export namespace PDFPageInfo {

export type PDFRotation = ValueOf<typeof PDFRotation>;
type ValueOf<T> = T[keyof T];
}
}
18 changes: 9 additions & 9 deletions src/forms/FormElement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export class FormElement {
/**
* The calculation order index.
*/
calculationOrderIndex: number;
calculationOrderIndex?: number;

/**
* Whether the form element is read-only.
Expand Down Expand Up @@ -115,12 +115,12 @@ export class FormElement {
/**
* The type name of the form.
*/
formTypeName: string;
formTypeName?: string;

/**
* The maximum length of the form element.
*/
maxLength: number;
maxLength?: number;

/**
* Whether scrolling is disabled.
Expand All @@ -139,15 +139,15 @@ export class FormElement {
this.exportValue = data.exportValue;
this.highlightColor = data.highlightColor;
this.calculationOrderIndex = data.calculationOrderIndex;
this.readOnly = data.readOnly;
this.required = data.required;
this.noExport = data.noExport;
this.readOnly = data.readOnly ?? false;
this.required = data.required ?? false;
this.noExport = data.noExport ?? false;
this.fieldName = data.fieldName;
this.fullyQualifiedFieldName = data.fullyQualifiedFieldName;
this.formTypeName = data.formTypeName;
this.maxLength = data.maxLength;
this.doNotScroll = data.doNotScroll;
this.isMultiline = data.isMultiline;
this.doNotScroll = data.doNotScroll ?? false;
this.isMultiline = data.isMultiline ?? false;
}
}

Expand Down Expand Up @@ -262,4 +262,4 @@ export class TextFieldFormElement extends FormElement {
this.fontSize = data.fontSize || 12;
this.fontName = data.fontName;
}
}
}
7 changes: 1 addition & 6 deletions src/measurements/Measurements.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,6 @@
* @property {Measurements.ScaleUnitTo} unitTo - The unit for the real world distance.
* @property {number} valueTo - A real world distance. The unit of this value is given by ```unitTo```.
*/
/**
* @interface Measurements
*/
export class Measurements {}

export interface MeasurementValueConfiguration {
/**
* Names are displayed in user interface and serve to help distinguish different scales.
Expand Down Expand Up @@ -177,4 +172,4 @@ export namespace Measurements {
export type ScaleUnitTo = ValueOf<typeof ScaleUnitTo>;
export type Precision = ValueOf<typeof Precision>;
type ValueOf<T> = T[keyof T];
}
}
8 changes: 4 additions & 4 deletions src/toolbar/Toolbar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @property {string} image - The image name (iOS) or resource ID (Android) for the toolbar button. Images must be included in the application bundle on iOS and specified as a drawable resource on Android.
* @property {string} [title] - The title of the toolbar button (Android only).
* @property {boolean} [showAsAction] - Whether the toolbar button should be displayed on the main toolbar, and not in the drop down menu (Android only).
* @property {boolean} [applyTemplate] - Whether the icon should be rendered using the system's tint color to match the color scheme of other toolbar buttons. Set this to false if your icon already contains color information that should be preserved.
* @property {boolean} [applyTemplate] - Whether the icon should be rendered using the system's tint color to match the color scheme of other toolbar buttons. Set this to false if your icon already contains color information that should be preserved.
*/
/**
* The toolbar buttons that should be displayed on the toolbar.
Expand All @@ -22,7 +22,7 @@
* @property { Toolbar.ToolbarItems } [rightBarButtonItems] The bar buttons to display on the right side of the navigation bar (iOS only).
* @property { Toolbar.ToolbarItems } [toolbarMenuItems] The toolbar buttons to display on the toolbar (Android only).
*/
export class Toolbar {
export interface Toolbar {
/**
* The bar buttons to display on the left side of the navigation bar (iOS only).
*/
Expand Down Expand Up @@ -55,7 +55,7 @@ export interface ToolbarItem {
*/
showAsAction?: boolean;
/**
* Whether the icon should be rendered using the system's tint color to match the color scheme of other toolbar buttons. Set this to false if your icon already contains color information that should be preserved.
* Whether the icon should be rendered using the system's tint color to match the color scheme of other toolbar buttons. Set this to false if your icon already contains color information that should be preserved.
*/
applyTemplate?: boolean;
}
Expand Down Expand Up @@ -125,4 +125,4 @@ export namespace Toolbar {
export type DefaultToolbarButton = ValueOf<typeof DefaultToolbarButton>;
export type PDFViewMode = ValueOf<typeof PDFViewMode>;
type ValueOf<T> = T[keyof T];
}
}
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
"./src/**/*",
],
"compilerOptions": {
"strict": true,
"rootDir": "src",
"skipLibCheck": true,
"outDir": "./lib",
}
}
}