Skip to content
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

chore: 🤖 remove unnecessary ts-expect-error #2138

Merged
merged 1 commit into from
Mar 10, 2023
Merged
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
15 changes: 6 additions & 9 deletions packages/rspack/src/compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -411,28 +411,25 @@ class Compiler {
if (err) {
cb(err);
} else {
// @ts-expect-error
cb(null);
cb(undefined);
}
});
}
// Safety: This method is only valid to call if the previous rebuild task is finished, or there will be data races.
rebuild(
modifiedFiles: ReadonlySet<string> | undefined,
removedFiles: ReadonlySet<string> | undefined,
cb: ((error?: Error) => void) | undefined
modifiedFiles?: ReadonlySet<string>,
removedFiles?: ReadonlySet<string>,
cb?: (error?: Error) => void
) {
const unsafe_rebuild = this.#instance.unsafe_rebuild;
const rebuild_cb = unsafe_rebuild.bind(
this.#instance
) as typeof unsafe_rebuild;
rebuild_cb([...(modifiedFiles ?? [])], [...(removedFiles ?? [])], err => {
if (err) {
// @ts-expect-error
cb(err);
cb && cb(err);
} else {
// @ts-expect-error
cb(null);
cb && cb(undefined);
}
});
}
Expand Down
3 changes: 1 addition & 2 deletions packages/rspack/src/watching.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ class Watching {
: () =>
console.log("build success, time cost", Date.now() - begin, "ms");

const onBuild = (err: Error) => {
const onBuild = (err?: Error) => {
if (err) return this._done(err);
// if (this.invalid) return this._done(null);
// @ts-expect-error
Expand All @@ -240,7 +240,6 @@ class Watching {
if (isRebuild) {
this.compiler.rebuild(modifiedFiles, deleteFiles, onBuild as any);
} else {
// @ts-expect-error
this.compiler.build(onBuild);
}
});
Expand Down