Skip to content

Commit

Permalink
Use declare fields to reduce bundle size (#104)
Browse files Browse the repository at this point in the history
  • Loading branch information
PaperStrike authored Aug 17, 2021
1 parent 40d3c96 commit 1de1fcd
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 13 deletions.
6 changes: 3 additions & 3 deletions babel.config.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"presets": [
["@babel/preset-typescript", {
"allowDeclareFields": true
}],
["@babel/preset-env", {
"bugfixes": true
}],
["@babel/preset-typescript", {
"allowDeclareFields": true
}]
],
"plugins": [
Expand Down
8 changes: 4 additions & 4 deletions src/libs/LazyHistory/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,22 @@ class LazyHistory {
/**
* The prefix of the generated key.
*/
idPrefix: string;
declare idPrefix: string;

/**
* The key used in `window.history.state`.
*/
historyKey: string;
declare historyKey: string;

/**
* The session key reflecting the current state.
*/
sessionKey!: string;
declare sessionKey: string;

/**
* The current state.
*/
state!: State;
declare state: State;

constructor(idPrefix: string, historyKey: string = idPrefix) {
this.idPrefix = idPrefix;
Expand Down
4 changes: 2 additions & 2 deletions src/libs/Submission/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ type FormContentAttributeNames = 'action' | 'enctype' | 'method' | 'target';
type SubmitterButtonContentAttributeNames = `form${Capitalize<FormContentAttributeNames>}`;

class Submission {
form: HTMLFormElement;
declare form: HTMLFormElement;

submitterButton: HTMLButtonElement | HTMLInputElement | null;
declare submitterButton: HTMLButtonElement | HTMLInputElement | null;

constructor(form: HTMLFormElement, submitter: HTMLElement | null) {
this.form = form;
Expand Down
4 changes: 2 additions & 2 deletions src/libs/executeScripts/Script.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ export const MIMETypes = [
];

export default class Script {
target: HTMLScriptElement;
declare target: HTMLScriptElement;

type?: 'classic' | 'module';
declare type?: 'classic' | 'module';

external = false;

Expand Down
2 changes: 1 addition & 1 deletion src/libs/executeScripts/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Script from './Script';

class Executor {
signal: AbortSignal | null;
declare signal: AbortSignal | null;

constructor(signal: AbortSignal | null) {
this.signal = signal;
Expand Down
2 changes: 1 addition & 1 deletion src/utils/DefaultTrigger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const getBrowsingContext = (target: string) => {
};

export default class DefaultTrigger {
pjax: Pjax;
declare pjax: Pjax;

constructor(pjax: Pjax) {
this.pjax = pjax;
Expand Down

0 comments on commit 1de1fcd

Please sign in to comment.