Remove use of 'any' type in 12 files (#58540)
This commit is contained in:
@@ -47,26 +47,27 @@ export const Tool = {
|
||||
type: 'block' as const,
|
||||
tagName: '',
|
||||
// Liquid template objects don't have TypeScript definitions
|
||||
templates: [] as any[],
|
||||
templates: [] as unknown[],
|
||||
|
||||
// tagToken and remainTokens are Liquid internal types without TypeScript definitions
|
||||
parse(tagToken: any, remainTokens: any) {
|
||||
this.tagName = tagToken.name
|
||||
parse(tagToken: unknown, remainTokens: unknown) {
|
||||
const token = tagToken as { name: string; getText: () => string }
|
||||
this.tagName = token.name
|
||||
this.templates = []
|
||||
|
||||
const stream = this.liquid.parser.parseStream(remainTokens)
|
||||
stream
|
||||
.on(`tag:end${this.tagName}`, () => stream.stop())
|
||||
// tpl is a Liquid template object without TypeScript definitions
|
||||
.on('template', (tpl: any) => this.templates.push(tpl))
|
||||
.on('template', (tpl: unknown) => this.templates.push(tpl))
|
||||
.on('end', () => {
|
||||
throw new Error(`tag ${tagToken.getText()} not closed`)
|
||||
throw new Error(`tag ${token.getText()} not closed`)
|
||||
})
|
||||
stream.start()
|
||||
},
|
||||
|
||||
// scope is a Liquid scope object, Generator yields/returns Liquid template values - no TypeScript definitions available
|
||||
*render(scope: any): Generator<any, any, any> {
|
||||
*render(scope: unknown): Generator<unknown, unknown, unknown> {
|
||||
const output = yield this.liquid.renderer.renderTemplates(this.templates, scope)
|
||||
return yield this.liquid.parseAndRender(template, {
|
||||
tagName: this.tagName,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { Response } from 'express'
|
||||
|
||||
import type { ExtendedRequest, Page } from '@/types'
|
||||
import type { ExtendedRequest, Page, Context } from '@/types'
|
||||
import contextualize from '@/frame/middleware/context/context'
|
||||
import features from '@/versions/middleware/features'
|
||||
import shortVersions from '@/versions/middleware/short-versions'
|
||||
@@ -55,7 +55,7 @@ export async function allDocuments(options: Options): Promise<AllDocument[]> {
|
||||
const next = () => {}
|
||||
const res = {}
|
||||
const pagePath = permalink.href
|
||||
const context: any = {}
|
||||
const context: Partial<Context> = {}
|
||||
const req = {
|
||||
path: pagePath,
|
||||
language: permalink.languageCode,
|
||||
@@ -68,7 +68,7 @@ export async function allDocuments(options: Options): Promise<AllDocument[]> {
|
||||
await contextualize(req as ExtendedRequest, res as Response, next)
|
||||
await shortVersions(req as ExtendedRequest, res as Response, next)
|
||||
req.context.page = page
|
||||
features(req as any, res as any, next)
|
||||
features(req as ExtendedRequest, res as Response, next)
|
||||
|
||||
const title = fields.includes('title')
|
||||
? await page.renderProp('title', req.context, { textOnly: true })
|
||||
|
||||
Reference in New Issue
Block a user