Skip to content
This repository has been archived by the owner on Dec 5, 2022. It is now read-only.

parseTemplate type definition does not match implementation #329

Open
atkinchris opened this issue May 9, 2020 · 0 comments · May be fixed by #328
Open

parseTemplate type definition does not match implementation #329

atkinchris opened this issue May 9, 2020 · 0 comments · May be fixed by #328

Comments

@atkinchris
Copy link

The type definition of parseTemplate is for the function before it closes over handledTags, insertBeforePipeTags, but this is not the function that is passed to fetchTemplate.

tailor/index.d.ts

Lines 60 to 64 in 7283c2f

type ParseTemplateFunction = (handledTags: string[], insertBeforePipeTags: string[]) => (
baseTemplate: string,
childTemplate: string,
fullRendering: boolean,
) => Promise<any>;

I think this should either be:

fetchTemplate?: (req: IncomingMessage, parseTemplate: ReturnType<ParseTemplateFunction>) => Promise<any>

Or changing the definition itself:

type ParseTemplateFunction = (baseTemplate: string,  childTemplate: string,  fullRendering: boolean) => Promise<any>;

I think childTemplate and fullRendering should be optional too, to match the implementation:

tailor/lib/transform.js

Lines 30 to 33 in 7283c2f

const slotMap =
childTemplate && typeof childTemplate === 'string'
? this._groupSlots(parse5.parseFragment(childTemplate, options))
: new Map();

fullRendering = true

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant