Skip to content

Commit 9e88813

Browse files
TheLarkInniclanton
andauthored
Update lib/interpolateName.ts
Co-authored-by: Ian Clanton-Thuon <[email protected]>
1 parent 54eb6d7 commit 9e88813

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

lib/interpolateName.ts

+17-11
Original file line numberDiff line numberDiff line change
@@ -116,19 +116,25 @@ export default function interpolateName(
116116
});
117117
}
118118

119+
interface ILoaderContextOptions {
120+
customInterpolateName(
121+
this: LoaderContext<object>,
122+
url: string,
123+
name: string | ((resourcePath: string, resourceQuery?: string) => string),
124+
options?: IInterpolateNameOptions
125+
): string;
126+
}
127+
type LegacyLoaderContext = LoaderContext<object> & {
128+
options?: ILoaderContextOptions;
129+
};
130+
const loaderContextOptions: ILoaderContextOptions | undefined = (
131+
loaderContext as LegacyLoaderContext
132+
).options;
119133
if (
120-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
121-
// @ts-ignore LoaderContext doesn't even have options defined on it?
122-
// If we chagned this to be `loaderContext.getOptions()` it would still not have
123-
// the customInterpolateName function defined on it.
124-
typeof loaderContext.options === "object" &&
125-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
126-
// @ts-ignore
127-
typeof loaderContext.options.customInterpolateName === "function"
134+
typeof loaderContextOptions === "object" &&
135+
typeof loaderContextOptions.customInterpolateName === "function"
128136
) {
129-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
130-
// @ts-ignore
131-
url = loaderContext.options.customInterpolateName.call(
137+
url = loaderContextOptions.customInterpolateName.call(
132138
loaderContext,
133139
url,
134140
name,

0 commit comments

Comments
 (0)