Skip to content

Commit 2c6182d

Browse files
serpentbladeclaude
andcommitted
fix(flatpickr): apply the flatpickr() engine-call cast to angular
flatpickr's Options narrows mode/position/monthSelectorType to string-literal unions, but the emitted props type them as plain string, so the inline options literal fails the flatpickr(Node, Options) overload (TS2769). The codegen already casts `flatpickr as any` at the call site for the vue leaf; angular — now ngc/tsc-compiled under the dist+source standard — hits the same error, so add the parallel cast for its signal/ElementRef call form. Unblocks the flatpickr angular leaf; svelte still skips (svelte-package doesn't body-check). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KcWqckxMNtbU5LGEAvYXEk
1 parent 8155733 commit 2c6182d

2 files changed

Lines changed: 16 additions & 2 deletions

File tree

packages/ui/flatpickr/packages/angular/src/Flatpickr.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ export class Flatpickr {
128128
const __plugins = this.plugins();
129129
const __locale = this.locale();
130130
const __firstDayOfWeek = this.firstDayOfWeek();
131-
this.instance = flatpickr(this.inputEl()!.nativeElement, {
131+
this.instance = (flatpickr as any)(this.inputEl()!.nativeElement, {
132132
mode: this.mode(),
133133
dateFormat: this.dateFormat(),
134134
altInput: this.altInput(),

packages/ui/flatpickr/scripts/codegen.mjs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,10 @@ function main() {
258258
// change; the internal `instance` binding is not part of the emitted .d.ts
259259
// surface). NOT an emitter edit (SCOPE FENCE): a durable, token-anchored,
260260
// fail-loud codegen aid, mirroring the cropper imageEl / fullcalendar `opts`
261-
// aids. The source-only svelte/angular leaves are never build-type-checked.
261+
// aids. The svelte leaf (svelte-package) still never strict-body-checks at
262+
// build; the ANGULAR leaf, however, now compiles via ng-packagr (real
263+
// ngc/tsc) under the dist+source standard, so it hits the same TS2769 and
264+
// gets the same cast (its call site uses the Angular signal/ElementRef form).
262265
let code = r.code;
263266
if (target === 'vue') {
264267
const NEEDLE = 'instance = flatpickr(inputElRef.value!, {';
@@ -271,6 +274,17 @@ function main() {
271274
}
272275
code = code.replace(NEEDLE, 'instance = (flatpickr as any)(inputElRef.value!, {');
273276
}
277+
if (target === 'angular') {
278+
const NEEDLE = 'this.instance = flatpickr(this.inputEl()!.nativeElement, {';
279+
if (!code.includes(NEEDLE)) {
280+
throw new Error(
281+
'codegen angular: flatpickr engine-call type-aid anchor not found — the Angular emit ' +
282+
`shape changed. Expected to cast:\n ${NEEDLE}\n` +
283+
'Re-confirm the emitted flatpickr() call and update (or remove) this aid.',
284+
);
285+
}
286+
code = code.replace(NEEDLE, 'this.instance = (flatpickr as any)(this.inputEl()!.nativeElement, {');
287+
}
274288
writeFileSync(resolve(leafSrc, cfg.file), code);
275289

276290
// Vue leaf: emit the dual-packaging build config + barrel + tsconfig + patch

0 commit comments

Comments
 (0)