From 7b0de45a627b4a9c336bf12d3574500de3577970 Mon Sep 17 00:00:00 2001 From: David Chau Date: Mon, 3 Aug 2026 19:06:56 -0400 Subject: [PATCH] docs: fix the playground, and typecheck the examples in CI MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The playground was a white screen: does not provide an export named 'searchCurrencies' 0.10.0 moved the currency helpers to their own entry point. examples/playground/src/App.tsx was updated by hand for the parse split; CurrencyCombobox.tsx was missed, and kept importing searchCurrencies, toFlagEmoji and their two types from the root. Nothing caught it. The playground has its own tsconfig, but CI never installed it, so it was the one piece of TypeScript in the repo that no run ever compiled. StackBlitz serves it straight from main, so the demo the README opens with was broken from 0.10.0 until now. tsconfig-examples.json maps the package name onto lib/ and typechecks the examples against the entry points as they are now — no install step, and it fails on exactly this. Reverting the import reproduces four TS2305s. docs: only examples/ and the typecheck script change; nothing in the published tarball moves, and StackBlitz reads main rather than npm. --- examples/playground/src/CurrencyCombobox.tsx | 2 +- examples/playground/src/styles.css.d.ts | 3 ++ package.json | 2 +- tsconfig-examples.json | 33 ++++++++++++++++++++ 4 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 examples/playground/src/styles.css.d.ts create mode 100644 tsconfig-examples.json diff --git a/examples/playground/src/CurrencyCombobox.tsx b/examples/playground/src/CurrencyCombobox.tsx index becef0d..717c4db 100644 --- a/examples/playground/src/CurrencyCombobox.tsx +++ b/examples/playground/src/CurrencyCombobox.tsx @@ -4,7 +4,7 @@ import { CurrencyPreset, searchCurrencies, toFlagEmoji -} from 'react-financial-input'; +} from 'react-financial-input/currency'; /* Copied verbatim from the library's own story, save for the import above. diff --git a/examples/playground/src/styles.css.d.ts b/examples/playground/src/styles.css.d.ts new file mode 100644 index 0000000..3d95a48 --- /dev/null +++ b/examples/playground/src/styles.css.d.ts @@ -0,0 +1,3 @@ +// A side-effect import of the opt-in stylesheet. TypeScript has no idea what a +// .css file is, and there is nothing to type — this just says it exists. +declare module 'react-financial-input/styles.css'; diff --git a/package.json b/package.json index 026c472..072e9c7 100644 --- a/package.json +++ b/package.json @@ -88,7 +88,7 @@ ], "scripts": { "build": "vite build && tsc -p ./tsconfig-build.json && node scripts/fixDeclarationImports.mjs", - "typecheck": "tsc --noEmit -p ./tsconfig.json", + "typecheck": "tsc --noEmit -p ./tsconfig.json && tsc --noEmit -p ./tsconfig-examples.json", "test": "vitest run", "test:watch": "vitest", "coverage": "vitest run --coverage", diff --git a/tsconfig-examples.json b/tsconfig-examples.json new file mode 100644 index 0000000..58fd517 --- /dev/null +++ b/tsconfig-examples.json @@ -0,0 +1,33 @@ +/* + The examples, typechecked against the library source. + + examples/playground has its own tsconfig for anyone who installs and runs + it, but nothing in CI installed it — so when the currency helpers moved to + their own entry point, App.tsx was updated by hand and CurrencyCombobox.tsx + was missed. The playground on StackBlitz went to a white screen with + "does not provide an export named 'searchCurrencies'", and nothing failed. + + Mapping the package name onto lib/ means the examples are checked against + the entry points as they are now, on every run, with no install step. + */ +{ + "compilerOptions": { + "target": "ES2022", + "lib": ["ES2022", "DOM", "DOM.Iterable"], + "module": "ESNext", + "moduleResolution": "bundler", + "jsx": "react-jsx", + "strict": true, + "skipLibCheck": true, + "noEmit": true, + "baseUrl": ".", + "paths": { + "react-financial-input": ["./lib/index.ts"], + "react-financial-input/parse": ["./lib/parse.ts"], + "react-financial-input/currency": ["./lib/currency.ts"], + "react-financial-input/events": ["./lib/events.ts"] + } + }, + "include": ["examples"], + "exclude": ["**/node_modules", "**/dist"] +}