diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 9a1674d..1d199f1 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -94,3 +94,25 @@ jobs: env: NUXT_VERSION: ${{ matrix.nuxt-version }} NUXT_TELEMETRY_DISABLED: '1' + + declarations: + timeout-minutes: 10 + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + typescript-version: ['6', '7'] + steps: + - uses: actions/checkout@v7 + - uses: actions/setup-node@v7 + with: + node-version: 22 + - uses: pnpm/action-setup@v6 + with: + cache: true + - run: pnpm install --frozen-lockfile + - run: pnpm dev:prepare + - name: Check published package types with TypeScript ${{ matrix.typescript-version }} + run: pnpm test:package + env: + TYPESCRIPT_VERSION: ${{ matrix.typescript-version }} diff --git a/README.md b/README.md index 046c1ac..b73ab6c 100644 --- a/README.md +++ b/README.md @@ -351,6 +351,8 @@ const attribution: AttributionSnapshot = { Supported UTM fields are the manual campaign parameters Google Analytics 4 documents: `utm_id`, `utm_source`, `utm_medium`, `utm_campaign`, `utm_source_platform`, `utm_term`, `utm_content`, `utm_creative_format`, and `utm_marketing_tactic`. Google click fields are `gclid`, `gad_source`, `gad_campaignid`, `gbraid`, `wbraid`, and `dclid`; Google Ads sends `gbraid` or `wbraid` alongside or instead of `gclid` for some iOS traffic. A nonempty value in any of these fields makes a visit a campaign visit. When a parameter repeats in the URL, each field, including configured click parameters, keeps its first nonempty value: `?utm_source=&utm_source=google&utm_source=newsletter` saves `google`. `clickParams` holds the values of the names listed in the `clickParams` option. `gclidParams`, `clickParams`, and `customParams` are optional. The package also exports `ModuleOptions`, `UTMParams`, `GCLIDParams`, `ClickParams`, `AdditionalInfo`, `BeforeTrackContext`, `NuxtUTMHooks`, and `UseNuxtUTMReturn`. +CI compiles the published declarations with TypeScript 5.9 and with the latest TypeScript 6 and 7 releases. Older TypeScript releases are untested. + ## Development Use the pnpm version pinned in `package.json`. The commands below assume Corepack is installed; see [pnpm installation](https://pnpm.io/installation) if needed. @@ -372,6 +374,8 @@ pnpm dev:build `test:package` checks the actual npm tarball from an isolated TypeScript consumer. `test:compatibility` also installs it in an independent Nuxt app, checks types, builds and generates static pages, and exercises campaign navigation, reload persistence, and form submission in Chromium. It tests the latest Nuxt 4 release by default; set `NUXT_VERSION=3` for Nuxt 3 or `NUXT_VERSION=npm:nuxt-nightly@5x` for the Nuxt 5 nightly. CI runs all three separately from the checks on each supported Node.js version, and a nightly failure does not fail the workflow. These are tested configurations, not runtime version restrictions. +Set `TYPESCRIPT_VERSION` to check the tarball with another TypeScript release, for example `TYPESCRIPT_VERSION=7 pnpm test:package`. Applications compile the published declarations with their own TypeScript, so CI also runs this check with each release listed in [Data and TypeScript](#data-and-typescript). + Use `pnpm dev` for the playground. See the [release documentation](docs/RELEASING.md) for preparing and publishing a version. ## License diff --git a/scripts/test-package.mjs b/scripts/test-package.mjs index b73da9b..3047b78 100644 --- a/scripts/test-package.mjs +++ b/scripts/test-package.mjs @@ -38,10 +38,29 @@ try { files: ['consumer.mts'], }), ) - execFileSync(process.execPath, [join(root, 'node_modules/typescript/bin/tsc'), '-p', directory], { - stdio: 'inherit', - }) + const compiler = typescriptCompiler(process.env.TYPESCRIPT_VERSION) + execFileSync(process.execPath, [compiler, '-p', directory], { stdio: 'inherit' }) if (process.argv.includes('--app')) await testCompatibility({ root, directory, tarball }) } finally { rmSync(directory, { recursive: true, force: true }) } + +// Consumers compile the published declarations with their own TypeScript, so CI checks newer +// releases than the one this repository builds with +function typescriptCompiler(version) { + if (!version) return join(root, 'node_modules/typescript/bin/tsc') + const prefix = join(directory, 'typescript') + const install = [ + 'install', + '--prefix', + prefix, + '--no-audit', + '--no-fund', + `typescript@${version}`, + ] + execFileSync('npm', install, { stdio: 'inherit' }) + const typescript = join(prefix, 'node_modules/typescript') + const { version: installed } = JSON.parse(readFileSync(join(typescript, 'package.json'), 'utf8')) + console.log(`Checking package types with TypeScript ${installed}`) + return join(typescript, 'bin/tsc') +}