Skip to content

Commit

Permalink
fix: replace type assertion with type guard (#4302)
Browse files Browse the repository at this point in the history
* fix: replace type assertion with type guard

* replace another assertion with type guard

* Review comments

Co-authored-by: Lukas Taegert-Atkinson <lukastaegert@users.noreply.github.com>
Co-authored-by: Lukas Taegert-Atkinson <lukas.taegert-atkinson@tngtech.com>
  • Loading branch information
3 people committed Dec 24, 2021
1 parent 9927fda commit a993426
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/Bundle.ts
Expand Up @@ -307,10 +307,10 @@ function validateOptionsForMultiChunkOutput(

function getIncludedModules(modulesById: Map<string, Module | ExternalModule>): Module[] {
return [...modulesById.values()].filter(
module =>
(module): module is Module =>
module instanceof Module &&
(module.isIncluded() || module.info.isEntry || module.includedDynamicImporters.length > 0)
) as Module[];
);
}

function addModuleToManualChunk(
Expand Down
5 changes: 2 additions & 3 deletions src/utils/getOriginalLocation.ts
Expand Up @@ -4,10 +4,9 @@ export function getOriginalLocation(
sourcemapChain: DecodedSourceMapOrMissing[],
location: { column: number; line: number; name?: string; source?: string }
): { column: number; line: number } {
// This cast is guaranteed. If it were a missing Map, it wouldn't have a mappings.
const filteredSourcemapChain = sourcemapChain.filter(
sourcemap => sourcemap.mappings
) as ExistingDecodedSourceMap[];
(sourcemap): sourcemap is ExistingDecodedSourceMap => !!sourcemap.mappings
);

while (filteredSourcemapChain.length > 0) {
const sourcemap = filteredSourcemapChain.pop()!;
Expand Down

0 comments on commit a993426

Please sign in to comment.