Skip to content

Commit 47c4ffb

Browse files
authored
refactor(types): improve typing (#1317)
1 parent cab769f commit 47c4ffb

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

Diff for: packages/compiler-sfc/src/compileTemplate.ts

+13-3
Original file line numberDiff line numberDiff line change
@@ -57,20 +57,30 @@ export interface SFCTemplateCompileOptions {
5757
*/
5858
transformAssetUrls?: AssetURLOptions | AssetURLTagConfig | boolean
5959
}
60+
61+
interface PreProcessor {
62+
render(
63+
source: string,
64+
options: any,
65+
cb: (err: Error | null, res: string) => void
66+
): void
67+
}
6068

6169
function preprocess(
6270
{ source, filename, preprocessOptions }: SFCTemplateCompileOptions,
63-
preprocessor: any
71+
preprocessor: PreProcessor
6472
): string {
6573
// Consolidate exposes a callback based API, but the callback is in fact
6674
// called synchronously for most templating engines. In our case, we have to
6775
// expose a synchronous API so that it is usable in Jest transforms (which
6876
// have to be sync because they are applied via Node.js require hooks)
69-
let res: any, err
77+
let res: string = ''
78+
let err: Error | null = null
79+
7080
preprocessor.render(
7181
source,
7282
{ filename, ...preprocessOptions },
73-
(_err: Error | null, _res: string) => {
83+
(_err, _res) => {
7484
if (_err) err = _err
7585
res = _res
7686
}

Diff for: packages/runtime-core/src/components/KeepAlive.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ function getName(comp: Component): string | void {
252252

253253
function matches(pattern: MatchPattern, name: string): boolean {
254254
if (isArray(pattern)) {
255-
return (pattern as any).some((p: string | RegExp) => matches(p, name))
255+
return pattern.some((p: string | RegExp) => matches(p, name))
256256
} else if (isString(pattern)) {
257257
return pattern.split(',').indexOf(name) > -1
258258
} else if (pattern.test) {

0 commit comments

Comments
 (0)