Skip to content

Type-check samples in CI - #1132

Merged
ChronosSF merged 5 commits into
vnextfrom
sstoychev/samples-type-check
Oct 22, 2026
Merged

ChronosSF merged 5 commits into
vnextfrom
sstoychev/samples-type-check

Conversation

@ChronosSF

@ChronosSF ChronosSF commented Oct 22, 2026 •

Copy link
Copy Markdown
Member

Adds npm run check:samples, runs it in CI right after astro check, and fixes what it found.

Why

astro check doesn't cover samples/. Most samples' own tsconfigs use moduleResolution: node, which can't see the types the IG packages publish through exports, so every IG component types as any. That's how vnext merged two color-picker samples that pass props IgrColorPicker doesn't have (placeholder, size).

The check

  • tsconfig.samples.json type-checks every published sample in one program. It uses the add:sample settings (bundler resolution) without strict, because the generated samples aren't written for strict mode. It takes about 30 s and about 2.7 GB of memory; running tsc -p once per sample would take about an hour.
  • It turns off noUncheckedSideEffectImports, as in the TypeScript 5.9 the samples build with. TypeScript 6 turns it on, and then rejects igniteui-react-grids/grids/combined, an untyped side-effect import that is valid.
  • scripts/lib/sample-globals.d.ts restores the global JSX.Element that @types/react 19 removed. 683 generated samples still annotate render() with it.
  • Any type error fails the check. It skips the samples in unpublished.json, as everything else does, and the ones in scripts/lib/skip-type-check.json (below).
  • In CI, the build still runs when a check fails, and the smoke tests run whenever the build succeeds, so a type error can't hide a broken build.

Fixed: 20 hand-maintained samples

Sample Fix
editors/x-date-picker/date-limits, editing, format create root before root.render(); they threw when run on their own
grids/grid/editing-excel-style, scheduling/date-range-picker/slots useRef(null); React 19 requires an initial value
grids/grid/localization IgrSelect change handler typed as its CustomEvent, reading e.detail.value
grids/grid/disabled-summaries, remote-paging-grid nothing; false positive, fixed in the config above
grids/grid-lite/sort-config-events, sort-config-pipeline readOnly, not the attribute name readonly
grids/grid-lite/styling-config-themes igc-* tags declared in React.JSX, which React 19 reads instead of the global JSX
inputs/badge/dot, icon, overview, tailwind-styling, type; inputs/color-picker/tailwind-styling dropped size, removed from all components in igniteui-webcomponents 5.0; the badge CSS already sets --ig-size
inputs/color-picker/styling dropped placeholder, which it doesn't have
inputs/button-group/custom-toggle selection="multiple", not selectionMode="multi" (behavior change, below)
interactions/chat/features createChatMarkdownRenderer({}); every option is optional

Verified against the previous build:

  • Screenshots: the 15 samples that render deterministically are pixel-identical, with no console errors.
  • The other 5 (random data or the current time):
    • the 3 x-date-pickers and grid-lite styling build to byte-identical chunks;
    • all 42 grid-lite ratings are still read-only;
    • none of the 5 log errors.
  • The one intended behavior change: custom-toggle's buttons were single-select; they now multi-select, matching the Web Components version of the sample.

Skipped: 5 generated samples

These are exported from igniteui-xplat-examples, so a fix made only here is lost at the next export. skip-type-check.json lists each with its error until the fix lands in xplat. They stay published: putting them in unpublished.json would also drop them from the site and the docs code viewer.

  • grids/data-grid/column-resizing: renders <DataGridColumnResizing/>; the component is GridColumnResizing
  • grids/data-grid/row-selection: root.render() without creating root
  • grids/grid/row-pinning-extra-column: rowList is an array; it has no toArray()
  • maps/geo-map/display-azure-imagery, display-bing-imagery: ref callbacks return a value, which React 19 reads as a cleanup function

Verify

npm run check:samples              # 986 samples checked, no errors
npx tsc -p tsconfig.samples.json   # every sample, skipped ones included

🤖 Generated with Claude Code

@ChronosSF
ChronosSF requested a review from rkaraivanov October 22, 2026 10:41
Base automatically changed from rkaraivanov/astro-migration to vnext October 22, 2026 10:48
Samples are outside `astro check`, and their own tsconfigs mostly use
`moduleResolution: node`, which cannot see the types the IG packages
publish through `exports`. Every IG component types as `any`, so a
prop the component does not have passes unnoticed; vnext merged two
color-picker samples that way.

`npm run check:samples` checks every published sample in one program
with tsconfig.samples.json: the add:sample settings, bundler
resolution, not strict. It takes about 30 seconds. A shim restores
the global JSX.Element that @types/react 19 removed, which 683
generated samples still use.

25 samples fail today. They are listed with the reason in
scripts/lib/known-type-errors.json, so CI blocks only new errors. A
listed sample that no longer fails also fails the check, so the list
only shrinks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The allowlist can silently accept unrelated diagnostics in samples with known failures, so the checker needs tightening before approval.

No open issues 🎉

What changed in this PR

Adds a shared TypeScript validation workflow for published samples, exposing npm run check:samples and running it in CI to catch errors that astro check does not cover.

Changes:

  • Adds shared sample compiler configuration and a React JSX compatibility declaration.
  • Adds the sample checker, known-error allowlist, and npm script.
  • Documents the command and runs it in CI after astro check.
File Summary Review
tsconfig.samples.json Defines shared compiler settings for sample type-checking. —
scripts/​lib/​sample-globals.d.ts Restores the global JSX.Element type used by generated samples. —
scripts/​lib/​known-type-errors.json Records currently known sample type failures. —
scripts/​check-samples.js Runs the shared check and validates expected failures. Moderate: Slug-level allowlisting can accept unrelated new diagnostics in an allowlisted sample.
README.md Documents the sample type-checking command and workflow. Nit: Clarify that the command checks every published sample, excluding unpublished samples.
package.json Adds the check:samples npm script. —
.github/​workflows/​ci.yml Runs sample type-checking in CI after astro check. —

Review effort: Lite

ChronosSF and others added 4 commits October 22, 2026 14:11
Drop the known-failures list: the check now fails on any type error in
a published sample, so CI stays red until the 25 samples it listed are
fixed. Samples in unpublished.json are still skipped, as everywhere
else.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A failed step skips every later one, so the red sample type check hid
whether the build and smoke tests pass. The build now runs regardless,
and the smoke tests whenever the build succeeds.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The errors `npm run check:samples` found in the 20 samples maintained
here, not exported from igniteui-xplat-examples:

- x-date-picker date-limits, editing, format: create `root` before
  root.render(), as the other x-date-picker samples do. They threw when
  run on their own; the browser strips the mount, so its build is
  byte-identical.
- grid editing-excel-style, date-range-picker slots: give useRef() an
  initial value, which React 19 requires.
- grid localization: type the IgrSelect change handler as the
  CustomEvent it is, reading the value from the selected item.
- grid-lite sort-config-events, sort-config-pipeline: readOnly, not the
  attribute name readonly. The ratings were read-only already.
- grid-lite styling-config-themes: declare its igc-* tags in React.JSX,
  which React 19 reads instead of the global JSX namespace.
- badge dot, icon, overview, tailwind-styling, type; color-picker
  tailwind-styling: drop size, removed from every component in
  igniteui-webcomponents 5.0. The badge CSS already sets --ig-size.
- color-picker styling: drop placeholder, which it does not have.
- button-group custom-toggle: selection="multiple", not
  selectionMode="multi". The buttons were single-select; they now
  multi-select, as in the Web Components sample.
- chat features: pass createChatMarkdownRenderer() its options object;
  every option is optional.

Screenshots of the 15 samples that render deterministically are
pixel-identical before and after.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Five samples exported from igniteui-xplat-examples fail the check; a
fix made here is lost at the next export. scripts/lib/skip-type-check.json
lists them with their errors until the fix lands there. They stay
published: unpublished.json would also drop them from the site and the
docs code viewer.

Turn off noUncheckedSideEffectImports, as in the TypeScript 5.9 the
samples build with: igniteui-react-grids/grids/combined is an untyped
side-effect entry, not an error in the two samples that import it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ChronosSF
ChronosSF merged commit fbf3779 into vnext Oct 22, 2026
4 checks passed
@ChronosSF
ChronosSF deleted the sstoychev/samples-type-check branch October 22, 2026 13:49
ChronosSF added a commit that referenced this pull request Oct 22, 2026
Bring in the Astro migration (#1110), the sample type check (#1132)
and AGENTS.md (#1133).

Conflicts: chip outlined, overview, size and styling. This branch had
already rewritten them as function components with new content, so its
side is kept, in vnext's style: no JSX.Element return type, which
React 19's types no longer declare, no unused React import, and the
`getElementById('root')!` mount.

The seven new chip samples (area, interaction-state, layout, remove,
state, tailwind-styling, types) get what vnext did to every sample:
no sandbox.config.json, README.md (tailwind-styling had ReadMe.md) in
the current format without the CodeSandbox link, the strict add:sample
tsconfig, and package versions from scripts/lib/versions.js.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants