Skip to content

Commit 6c6248e

Browse files
committed
refactor(@angular/build): add explicit type annotations to avoid inferred types
This refactor resolves an issue where the inferred type of `renderSassStylesheet` required an external reference, which could affect portability. Fixes the following error: ``` packages/angular/build/src/tools/sass/worker.ts:59:31 - error TS2742: The inferred type of 'renderSassStylesheet' cannot be named without a reference to '../../../../../../external/npm/node_modules/source-map-js/source-map'. This is likely not portable. A type annotation is necessary. ``` Explicit type annotation added to `renderSassStylesheet` function to prevent reliance on inferred types. **Note:** Ensure compatibility with Windows Bazel builds.
1 parent 26c6d2d commit 6c6248e

File tree

1 file changed

+24
-1
lines changed
  • packages/angular/build/src/tools/sass

1 file changed

+24
-1
lines changed

packages/angular/build/src/tools/sass/worker.ts

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,29 @@ interface RenderRequestMessage {
5656
rebase: boolean;
5757
}
5858

59-
export default async function renderSassStylesheet(request: RenderRequestMessage) {
59+
interface RenderResult {
60+
warnings: SerializableWarningMessage[] | undefined;
61+
result: {
62+
css: string;
63+
loadedUrls: string[];
64+
sourceMap?: RawSourceMap;
65+
};
66+
}
67+
68+
interface RenderError {
69+
warnings: SerializableWarningMessage[] | undefined;
70+
error: {
71+
message: string;
72+
stack?: string;
73+
span?: Omit<SourceSpan, 'url'> & { url?: string };
74+
sassMessage?: string;
75+
sassStack?: string;
76+
};
77+
}
78+
79+
export default async function renderSassStylesheet(
80+
request: RenderRequestMessage,
81+
): Promise<RenderResult | RenderError> {
6082
const { importerChannel, hasLogger, source, options, rebase } = request;
6183

6284
const entryDirectory = dirname(options.url);
@@ -164,6 +186,7 @@ export default async function renderSassStylesheet(request: RenderRequestMessage
164186
warnings,
165187
result: {
166188
...result,
189+
sourceMap: result.sourceMap as unknown as RawSourceMap | undefined,
167190
// URL is not serializable so to convert to string here and back to URL in the parent.
168191
loadedUrls: result.loadedUrls.map((p) => fileURLToPath(p)),
169192
},

0 commit comments

Comments
 (0)