Skip to content

Commit 2bef422

Browse files
authored
chore(types): provide type for source maps (#5670)
1 parent 7351f73 commit 2bef422

File tree

4 files changed

+7
-4
lines changed

4 files changed

+7
-4
lines changed

packages/@lwc/compiler/src/transformers/shared.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@
44
* SPDX-License-Identifier: MIT
55
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
66
*/
7+
import type { BabelFileResult } from '@babel/core';
78
import type { CompilerDiagnostic } from '@lwc/errors';
89

910
/** The object returned after transforming code. */
1011
export interface TransformResult {
1112
/** The compiled source code. */
1213
code: string;
1314
/** The generated source map. */
14-
map: unknown;
15+
map: BabelFileResult['map'];
1516
/** Any diagnostic warnings that may have occurred. */
1617
warnings?: CompilerDiagnostic[];
1718
/**

packages/@lwc/compiler/src/transformers/style.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import * as styleCompiler from '@lwc/style-compiler';
88
import { normalizeToCompilerError, TransformerErrors, CompilerAggregateError } from '@lwc/errors';
99

10+
import type { BabelFileResult } from '@babel/core';
1011
import type { NormalizedTransformOptions } from '../options';
1112
import type { TransformResult } from './shared';
1213

@@ -63,6 +64,6 @@ export default function styleTransform(
6364
// the styles doesn't make sense, the transform returns an empty mappings.
6465
return {
6566
code: res.code,
66-
map: { mappings: '' },
67+
map: { mappings: '' } as BabelFileResult['map'],
6768
};
6869
}

packages/@lwc/compiler/src/transformers/template.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
} from '@lwc/errors';
1414
import { compile } from '@lwc/template-compiler';
1515

16+
import type { BabelFileResult } from '@babel/core';
1617
import type { NormalizedTransformOptions } from '../options';
1718
import type { TransformResult } from './shared';
1819

@@ -93,7 +94,7 @@ export default function templateTransform(
9394
// the template doesn't make sense, the transform returns an empty mappings.
9495
return {
9596
code: result.code,
96-
map: { mappings: '' },
97+
map: { mappings: '' } as BabelFileResult['map'],
9798
warnings,
9899
cssScopeTokens: result.cssScopeTokens,
99100
};

packages/@lwc/ssr-compiler/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import type { ComponentTransformOptions, TemplateTransformOptions } from './shar
1212

1313
export interface CompilationResult {
1414
code: string;
15-
map: unknown;
15+
map: undefined;
1616
}
1717

1818
export function compileComponentForSSR(

0 commit comments

Comments
 (0)