Skip to content

Commit 0b1ae5a

Browse files
authored
chore: enable verbatimModuleSyntax (#368)
TypeScript 5.0 introduce a new option [verbatimModuleSyntax](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-0.html#--verbatimmodulesyntax).
1 parent 154a5be commit 0b1ae5a

File tree

324 files changed

+656
-851
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

324 files changed

+656
-851
lines changed

.github/workflows/build.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
node-version-file: 'package.json'
1919
cache: 'pnpm'
2020
- run: pnpm install --frozen-lockfile
21-
- run: pnpm tsc
21+
- run: pnpm type-checks
2222
- run: pnpm lint
2323
- run: pnpm test
2424
- run: pnpm package

jest.config.cjs

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/** @type {import('ts-jest').JestConfigWithTsJest} */
2+
module.exports = {
3+
verbose: true,
4+
testMatch: ["<rootDir>/test/**/*.test.+(ts|tsx|js|jsx)"],
5+
transform: {
6+
// Use isolated tsconfig for jest to disable verbatimModuleSyntax
7+
// https://github.com/kulshekhar/ts-jest/issues/4081
8+
"^.+\\.(ts|tsx)$": ["ts-jest", { tsconfig: "tsconfig.jest.json" }],
9+
},
10+
setupFiles: ["./test/main.ts"],
11+
};

jest.config.ts

-11
This file was deleted.

src/background/Application.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ import { injectable, inject } from "inversify";
22
import BackgroundMessageListener from "./messaging/BackgroundMessageListener";
33
import FindPortListener from "./messaging/FindPortListener";
44
import VersionUseCase from "./usecases/VersionUseCase";
5-
import FindRepositoryImpl from "./repositories/FindRepository";
6-
import ReadyFrameRepository from "./repositories/ReadyFrameRepository";
5+
import type { FindRepository } from "./repositories/FindRepository";
6+
import type { ReadyFrameRepository } from "./repositories/ReadyFrameRepository";
77
import SettingsEventUseCase from "./usecases/SettingsEventUseCase";
8-
import FrameClient from "./clients/FrameClient";
8+
import type { FrameClient } from "./clients/FrameClient";
99
import AddonEnabledEventUseCase from "./usecases/AddonEnabledEventUseCase";
10-
import LastSelectedTabRepository from "./repositories/LastSelectedTabRepository";
10+
import type { LastSelectedTabRepository } from "./repositories/LastSelectedTabRepository";
1111
import ModeUseCase from "./usecases/ModeUseCase";
1212
import HintModeUseCase from "./usecases/HintModeUseCase";
1313

@@ -19,7 +19,7 @@ export default class Application {
1919
@inject(VersionUseCase)
2020
private readonly versionUseCase: VersionUseCase,
2121
@inject("FindRepository")
22-
private readonly findRepository: FindRepositoryImpl,
22+
private readonly findRepository: FindRepository,
2323
@inject("ReadyFrameRepository")
2424
private readonly frameRepository: ReadyFrameRepository,
2525
@inject("LastSelectedTabRepository")

src/background/clients/AddonEnabledClient.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { injectable } from "inversify";
22
import { newSender } from "./ContentMessageSender";
33

4-
export default interface AddonEnabledClient {
4+
export interface AddonEnabledClient {
55
enable(tabId: number): Promise<void>;
66

77
disable(tabId: number): Promise<void>;

src/background/clients/ConsoleClient.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { injectable } from "inversify";
22
import { newSender } from "./ConsoleMessageSender";
33

4-
export default interface ConsoleClient {
4+
export interface ConsoleClient {
55
showCommand(tabId: number, command: string): Promise<void>;
66

77
showFind(tabId: number): Promise<void>;

src/background/clients/ConsoleFrameClient.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { injectable } from "inversify";
22
import { newSender } from "./ContentMessageSender";
33

4-
export default interface ConsoleFrameClient {
4+
export interface ConsoleFrameClient {
55
resize(tabId: number, width: number, height: number): Promise<void>;
66
}
77

src/background/clients/ConsoleMessageSender.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import type { Schema, Key, Request } from "../../messaging/schema/console";
22
import { Sender } from "../../messaging";
33

4-
type ConsoleMessageSender = Sender<Schema>;
5-
64
export const newSender = (tabId: number, frameId?: number) => {
75
const sender = new Sender<Schema>((type: Key, args: Request) => {
86
if (process.env.NODE_ENV === "development") {
@@ -17,4 +15,4 @@ export const newSender = (tabId: number, frameId?: number) => {
1715
return sender;
1816
};
1917

20-
export default ConsoleMessageSender;
18+
export type ConsoleMessageSender = Sender<Schema>;

src/background/clients/ContentMessageClient.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { injectable } from "inversify";
22
import { newSender } from "./ContentMessageSender";
33

4-
export default interface ContentMessageClient {
4+
export interface ContentMessageClient {
55
scrollTo(
66
tabId: number,
77
frameId: number,

src/background/clients/ContentMessageSender.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import type { Schema, Key, Request } from "../../messaging/schema/content";
22
import { Sender } from "../../messaging";
33

4-
type ContentMessageSender = Sender<Schema>;
5-
64
export const newSender = (tabId: number, frameId?: number) => {
75
const sender = new Sender<Schema>((type: Key, args: Request) => {
86
if (process.env.NODE_ENV === "development") {
@@ -18,4 +16,4 @@ export const newSender = (tabId: number, frameId?: number) => {
1816
return sender;
1917
};
2018

21-
export default ContentMessageSender;
19+
export type ContentMessageSender = Sender<Schema>;

src/background/clients/FindClient.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { injectable } from "inversify";
22
import { newSender } from "./ContentMessageSender";
3-
import type FindQuery from "../../shared/FindQuery";
3+
import type { FindQuery } from "../../shared/findQuery";
44

5-
export default interface FindClient {
5+
export interface FindClient {
66
findNext(tabId: number, frameId: number, query: FindQuery): Promise<boolean>;
77

88
findPrev(tabId: number, frameId: number, query: FindQuery): Promise<boolean>;

src/background/clients/FrameClient.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { injectable } from "inversify";
22
import { newSender } from "./ContentMessageSender";
33

4-
export default interface FrameClient {
4+
export interface FrameClient {
55
notifyFrameId(tabId: number, frameId: number): Promise<void>;
66
}
77

src/background/clients/HintClient.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { injectable } from "inversify";
22
import { newSender } from "./ContentMessageSender";
3-
import type HTMLElementType from "../../shared/HTMLElementType";
3+
import type { HTMLElementType } from "../../shared/HTMLElementType";
44

55
export type Point = {
66
x: number;
@@ -12,7 +12,7 @@ export type Size = {
1212
height: number;
1313
};
1414

15-
export default interface HintClient {
15+
export interface HintClient {
1616
lookupTargets(
1717
tabId: number,
1818
frameId: number,

src/background/clients/ModeClient.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { injectable } from "inversify";
22
import { newSender } from "./ContentMessageSender";
3-
import Mode from "../../shared/Mode";
3+
import { Mode } from "../../shared/mode";
44

5-
export default interface ModeClient {
5+
export interface ModeClient {
66
setMode(tabid: number, mode: Mode): Promise<void>;
77
}
88

src/background/clients/NavigateClient.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { injectable } from "inversify";
22
import { newSender } from "./ContentMessageSender";
33

4-
export default interface NavigateClient {
4+
export interface NavigateClient {
55
historyNext(tabId: number): Promise<void>;
66

77
historyPrev(tabId: number): Promise<void>;

src/background/clients/TopFrameClient.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export type Point = {
1111
y: number;
1212
};
1313

14-
export default interface TopFrameClient {
14+
export interface TopFrameClient {
1515
getWindowViewport(tabId: number): Promise<Rect>;
1616

1717
getFramePosition(tabId: number, frameId: number): Promise<Point | undefined>;

src/background/command/AddBookmarkCommand.ts

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
import type Command from "./Command";
2-
import type { CommandContext } from "./Command";
3-
import type { Completions } from "./Command";
4-
import type ConsoleClient from "../clients/ConsoleClient";
1+
import type { Command, CommandContext, Completions } from "./types";
2+
import type { ConsoleClient } from "../clients/ConsoleClient";
53

64
class AddBookmarkCommand implements Command {
75
constructor(private readonly consoleClient: ConsoleClient) {}

src/background/command/BufferCommand.ts

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
import type Command from "./Command";
2-
import type { CommandContext } from "./Command";
3-
import type { Completions } from "./Command";
4-
import type LastSelectedTabRepository from "../repositories/LastSelectedTabRepository";
1+
import type { Command, CommandContext, Completions } from "./types";
2+
import type { LastSelectedTabRepository } from "../repositories/LastSelectedTabRepository";
53
import BufferCommandHelper from "./BufferCommandHelper";
64

75
class BufferCommand implements Command {

src/background/command/BufferCommandHelper.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { Completions } from "../../shared/Completions";
2-
import LastSelectedTabRepository from "../repositories/LastSelectedTabRepository";
1+
import type { Completions } from "../../shared/completions";
2+
import type { LastSelectedTabRepository } from "../repositories/LastSelectedTabRepository";
33

44
export default class BufferCommandHelper {
55
constructor(

src/background/command/BufferDeleteCommand.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
import type Command from "./Command";
2-
import type { CommandContext } from "./Command";
3-
import type { Completions } from "./Command";
1+
import type { Command, CommandContext, Completions } from "./types";
42
import type BufferCommandHelper from "./BufferCommandHelper";
53

64
class BufferDeleteCommand implements Command {

src/background/command/BufferDeletesCommand.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
import type Command from "./Command";
2-
import type { CommandContext } from "./Command";
3-
import type { Completions } from "./Command";
1+
import type { Command, CommandContext, Completions } from "./types";
42
import type BufferCommandHelper from "./BufferCommandHelper";
53

64
class BDeletesCommand implements Command {

src/background/command/CommandRegistry.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import Command from "./Command";
1+
import type { Command } from "./types";
22

3-
export default interface CommandRegistry {
3+
export interface CommandRegistry {
44
register(cmd: Command): void;
55

66
getCommand(name: string): Command | undefined;

src/background/command/HelpCommand.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
import type Command from "./Command";
2-
import type { CommandContext } from "./Command";
3-
import type { Completions } from "./Command";
1+
import type { Command, CommandContext, Completions } from "./types";
42

53
const url = "https://ueokande.github.io/vimmatic/";
64

src/background/command/OpenCommand.ts

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
import type Command from "./Command";
2-
import type { CommandContext, Completions } from "./Command";
1+
import type { Command, CommandContext, Completions } from "./types";
32
import * as urls from "../../shared/urls";
4-
import type SearchEngineSettings from "../settings/SearchEngineSettings";
5-
import type PropertySettings from "../settings/PropertySettings";
3+
import type { SearchEngineSettings } from "../settings/SearchEngineSettings";
4+
import type { PropertySettings } from "../settings/PropertySettings";
65
import OpenCommandHelper from "./OpenCommandHelper";
76

87
class OpenCommand implements Command {

src/background/command/OpenCommandHelper.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import type { Completions, CompletionItem } from "./Command";
1+
import type { Completions, CompletionItem } from "./types";
22
import * as filters from "./filters";
3-
import type SearchEngineSettings from "../settings/SearchEngineSettings";
4-
import type PropertySettings from "../settings/PropertySettings";
3+
import type { SearchEngineSettings } from "../settings/SearchEngineSettings";
4+
import type { PropertySettings } from "../settings/PropertySettings";
55

66
const COMPLETION_ITEM_LIMIT = 10;
77

src/background/command/QuitAllCommand.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import type Command from "./Command";
2-
import type { CommandContext, Completions } from "./Command";
1+
import type { Command, CommandContext, Completions } from "./types";
32

43
class QuitAllCommand implements Command {
54
names(): string[] {

src/background/command/QuitCommand.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import type Command from "./Command";
2-
import type { CommandContext, Completions } from "./Command";
1+
import type { Completions, Command, CommandContext } from "./types";
32

43
class QuitCommand implements Command {
54
names(): string[] {

src/background/command/SetCommand.ts

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
import type Command from "./Command";
2-
import type { CommandContext, Completions } from "./Command";
3-
import type PropertySettings from "../settings/PropertySettings";
4-
import type PropertyRegistry from "../property/PropertyRegistry";
5-
import type ConsoleClient from "../clients/ConsoleClient";
1+
import type { Command, CommandContext, Completions } from "./types";
2+
import type { PropertySettings } from "../settings/PropertySettings";
3+
import type { PropertyRegistry } from "../property/PropertyRegistry";
4+
import type { ConsoleClient } from "../clients/ConsoleClient";
65

76
const mustNumber = (v: any): number => {
87
const num = Number(v);

src/background/command/TabOpenCommand.ts

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
import type Command from "./Command";
2-
import type { CommandContext, Completions } from "./Command";
1+
import type { Command, CommandContext, Completions } from "./types";
32
import * as urls from "../../shared/urls";
4-
import type SearchEngineSettings from "../settings/SearchEngineSettings";
5-
import type PropertySettings from "../settings/PropertySettings";
3+
import type { SearchEngineSettings } from "../settings/SearchEngineSettings";
4+
import type { PropertySettings } from "../settings/PropertySettings";
65
import OpenCommandHelper from "./OpenCommandHelper";
76

87
class TabOpenCommand implements Command {

src/background/command/WindowOpenCommand.ts

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
import type Command from "./Command";
2-
import type { CommandContext, Completions } from "./Command";
1+
import type { Completions, Command, CommandContext } from "./types";
32
import * as urls from "../../shared/urls";
4-
import type SearchEngineSettings from "../settings/SearchEngineSettings";
5-
import type PropertySettings from "../settings/PropertySettings";
3+
import type { SearchEngineSettings } from "../settings/SearchEngineSettings";
4+
import type { PropertySettings } from "../settings/PropertySettings";
65
import OpenCommandHelper from "./OpenCommandHelper";
76

87
class WindowOpenCommand implements Command {

src/background/command/index.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ import SetCommand from "./SetCommand";
1111
import TabOpenCommand from "./TabOpenCommand";
1212
import WindowOpenCommand from "./WindowOpenCommand";
1313
import BufferCommandHelper from "./BufferCommandHelper";
14-
import PropertyRegistry from "../property/PropertyRegistry";
15-
import PropertySettings from "../settings/PropertySettings";
16-
import SearchEngineSettings from "../settings/SearchEngineSettings";
17-
import CommandRegistry, { CommandRegistryImpl } from "./CommandRegistry";
18-
import LastSelectedTabRepository from "../repositories/LastSelectedTabRepository";
19-
import ConsoleClient from "../clients/ConsoleClient";
14+
import type { PropertyRegistry } from "../property/PropertyRegistry";
15+
import type { PropertySettings } from "../settings/PropertySettings";
16+
import type { SearchEngineSettings } from "../settings/SearchEngineSettings";
17+
import { type CommandRegistry, CommandRegistryImpl } from "./CommandRegistry";
18+
import type { LastSelectedTabRepository } from "../repositories/LastSelectedTabRepository";
19+
import type { ConsoleClient } from "../clients/ConsoleClient";
2020

2121
@injectable()
2222
export class CommandRegistryFactory {

src/background/command/Command.ts renamed to src/background/command/types.ts

+2-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type {
22
Completions as CompletionsType,
33
CompletionGroup as CompletionGroupType,
44
CompletionItem as CompletionItemType,
5-
} from "../../shared/Completions";
5+
} from "../../shared/completions";
66

77
export type Completions = CompletionsType;
88
export type CompletionGroup = CompletionGroupType;
@@ -16,7 +16,7 @@ export type CommandContext = {
1616
};
1717
};
1818

19-
interface Command {
19+
export interface Command {
2020
names(): string[];
2121

2222
fullname(): string;
@@ -27,5 +27,3 @@ interface Command {
2727

2828
exec(ctx: CommandContext, force: boolean, args: string): Promise<void>;
2929
}
30-
31-
export default Command;

src/background/controllers/CommandController.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { injectable, inject } from "inversify";
2-
import { Completions } from "../../shared/Completions";
2+
import type { Completions } from "../../shared/completions";
33
import CommandUseCase from "../usecases/CommandUseCase";
4-
import RequestContext from "../messaging/RequestContext";
4+
import type { RequestContext } from "../messaging/types";
55

66
@injectable()
77
export default class CommandController {

src/background/controllers/ConsoleController.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { injectable, inject } from "inversify";
22
import ConsoleUseCase from "../usecases/ConsoleUseCase";
3-
import RequestContext from "../messaging/RequestContext";
3+
import type { RequestContext } from "../messaging/types";
44

55
@injectable()
66
export default class ConsoleController {

src/background/controllers/FindController.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { injectable, inject } from "inversify";
2-
import { Completions } from "../../shared/Completions";
2+
import type { Completions } from "../../shared/completions";
33
import FindUseCase from "../usecases/FindUseCase";
4-
import RequestContext from "../messaging/RequestContext";
4+
import type { RequestContext } from "../messaging/types";
55

66
@injectable()
77
export default class FindController {

0 commit comments

Comments
 (0)