An open source design system that's fully customizable and agent ready
TypeScript
fix(build): emit fully specified relative specifiers in published declarations (#7711)
Harjoth Kharabc3d4490e5f0
diff --git a/.changeset/published-type-declarations-use-fully-specified--rphc.md b/.changeset/published-type-declarations-use-fully-specified--rphc.mdnew file mode 100644index 0000000000..d74f6c0192--- /dev/null+++ b/.changeset/published-type-declarations-use-fully-specified--rphc.md@@ -0,0 +1,7 @@+---+'@astryxdesign/core': patch+'@astryxdesign/richtext': patch+---++[fix] Published type declarations use fully specified relative imports, so projects compiled with `moduleResolution: NodeNext` resolve them (#7702)+@harjothkharadiff --git a/packages/charts/package.json b/packages/charts/package.jsonindex ba61bd8cb1..c749aee23e 100644--- a/packages/charts/package.json+++ b/packages/charts/package.json@@ -50,7 +50,7 @@},"scripts": {"prepack": "pnpm build",- "build": "node ../../scripts/clean-dist.mjs && pnpm build:esm && tsc --project tsconfig.build.json && pnpm build:css && node ../../scripts/check-no-dev-jsx.mjs && node ../../scripts/check-fully-specified.mjs",+ "build": "node ../../scripts/clean-dist.mjs && pnpm build:esm && tsc --project tsconfig.build.json && node ../../scripts/add-declaration-extensions.mjs && pnpm build:css && node ../../scripts/check-no-dev-jsx.mjs && node ../../scripts/check-fully-specified.mjs","build:esm": "babel src --out-dir dist --extensions .ts,.tsx --out-file-extension .js --ignore \"**/*.test.ts,**/*.test.tsx,**/__tests__/**,**/*.perf.test.*,**/*.doc.mjs,**/*.d.ts,**/*.css,**/*.css.d.ts\" --config-file ./babel.config.json","build:css": "node ../../scripts/build-css.mjs --package charts","dev": "babel src --watch --out-dir dist --extensions .ts,.tsx --out-file-extension .js --ignore \"**/*.test.*,**/*.doc.mjs,**/*.d.ts,**/*.css*\" --config-file ./babel.config.json",diff --git a/packages/core/package.json b/packages/core/package.jsonindex 6338d80e14..8f02333465 100644--- a/packages/core/package.json+++ b/packages/core/package.json@@ -789,7 +789,7 @@"scripts": {"prepack": "pnpm build","postinstall": "node scripts/postinstall.mjs",- "build": "node ../../scripts/clean-dist.mjs && pnpm build:i18n && pnpm build:esm && tsc --project tsconfig.build.json && pnpm build:css && node ../../scripts/check-no-dev-jsx.mjs && node ../../scripts/check-fully-specified.mjs",+ "build": "node ../../scripts/clean-dist.mjs && pnpm build:i18n && pnpm build:esm && tsc --project tsconfig.build.json && node ../../scripts/add-declaration-extensions.mjs && pnpm build:css && node ../../scripts/check-no-dev-jsx.mjs && node ../../scripts/check-fully-specified.mjs","build:i18n": "node ../../scripts/generate-i18n-runtime.mjs && node scripts/build-pseudo-locale.mjs","build:esm": "babel src --out-dir dist --extensions .ts,.tsx --out-file-extension .js --ignore \"**/*.test.ts,**/*.test.tsx,**/__tests__/**,**/*.perf.test.*,**/*.doc.mjs,**/*.d.ts,**/*.css,**/*.css.d.ts\" --config-file ./babel.config.json","build:css": "node ../../scripts/build-css.mjs",diff --git a/packages/lab/package.json b/packages/lab/package.jsonindex 20aa0b94ad..e8ed60b816 100644--- a/packages/lab/package.json+++ b/packages/lab/package.json@@ -50,7 +50,7 @@},"scripts": {"prepack": "pnpm build",- "build": "node ../../scripts/clean-dist.mjs && pnpm build:esm && tsc --project tsconfig.build.json && pnpm build:css && node ../../scripts/check-no-dev-jsx.mjs && node ../../scripts/check-fully-specified.mjs",+ "build": "node ../../scripts/clean-dist.mjs && pnpm build:esm && tsc --project tsconfig.build.json && node ../../scripts/add-declaration-extensions.mjs && pnpm build:css && node ../../scripts/check-no-dev-jsx.mjs && node ../../scripts/check-fully-specified.mjs","build:esm": "babel src --out-dir dist --extensions .ts,.tsx --out-file-extension .js --ignore \"**/*.test.ts,**/*.test.tsx,**/__tests__/**,**/*.perf.test.*,**/*.doc.mjs,**/*.d.ts,**/*.css,**/*.css.d.ts\" --config-file ./babel.config.json","build:css": "node ../../scripts/build-css.mjs --package lab","dev": "babel src --watch --out-dir dist --extensions .ts,.tsx --out-file-extension .js --ignore \"**/*.test.*,**/*.doc.mjs,**/*.d.ts,**/*.css*\" --config-file ./babel.config.json",diff --git a/packages/richtext/package.json b/packages/richtext/package.jsonindex 76f016ebbf..d00e237611 100644--- a/packages/richtext/package.json+++ b/packages/richtext/package.json@@ -53,7 +53,7 @@},"scripts": {"prepack": "pnpm build",- "build": "node ../../scripts/clean-dist.mjs && pnpm build:esm && tsc --project tsconfig.build.json && pnpm build:css && node ../../scripts/check-no-dev-jsx.mjs && node ../../scripts/check-fully-specified.mjs",+ "build": "node ../../scripts/clean-dist.mjs && pnpm build:esm && tsc --project tsconfig.build.json && node ../../scripts/add-declaration-extensions.mjs && pnpm build:css && node ../../scripts/check-no-dev-jsx.mjs && node ../../scripts/check-fully-specified.mjs","build:esm": "babel src --out-dir dist --extensions \".ts,.tsx\" --out-file-extension \".js\" --ignore \"**/*.test.ts,**/*.test.tsx,**/__tests__/**,**/*.perf.test.*,**/*.doc.mjs,**/*.d.ts,**/*.css,**/*.css.d.ts\" --config-file ./babel.config.json","build:css": "node ../../scripts/build-css.mjs --package richtext","dev": "babel src --watch --out-dir dist --extensions \".ts,.tsx\" --out-file-extension \".js\" --ignore \"**/*.test.*,**/*.doc.mjs,**/*.d.ts,**/*.css*\" --config-file ./babel.config.json",diff --git a/scripts/add-declaration-extensions.mjs b/scripts/add-declaration-extensions.mjsnew file mode 100644index 0000000000..c9f504d364--- /dev/null+++ b/scripts/add-declaration-extensions.mjs@@ -0,0 +1,111 @@+#!/usr/bin/env node+// Copyright (c) Meta Platforms, Inc. and affiliates.++/**+ * Build step: make every relative specifier in the emitted declarations+ * fully specified.+ *+ * `tsc --emitDeclarationOnly` copies source specifiers into the emitted .d.ts+ * files unchanged, so './Selector' and '../Button' reach consumers without an+ * extension. Bundler resolution tolerates that, but strict NodeNext consumers+ * reject them (TS2834/TS2835) and lose the types behind them (#7702). This+ * applies the rule babel-plugin-add-extensions.cjs applies to the runtime+ * files, resolved against the emitted declarations instead of the source:+ *+ * '.' / '..' → './index.js' / '../index.js'+ * './x' (x.d.ts exists) → './x.js'+ * './x' (x/index.d.ts exists) → './x/index.js'+ *+ * A file wins over a directory of the same name, as in TypeScript's own+ * lookup. Specifiers that already carry an extension, and specifiers that+ * resolve to nothing, are left alone; check-fully-specified.mjs reports the+ * latter. Comment lines are skipped, like the check, so JSDoc examples keep+ * their wording.+ *+ * Usage: node <repo-root>/scripts/add-declaration-extensions.mjs (run from+ * a package root, right after `tsc --project tsconfig.build.json`)+ */+import fs from 'node:fs';+import path from 'node:path';+import {fileURLToPath} from 'node:url';++const FULLY_SPECIFIED = /\.(?:js|mjs|cjs|json|css)$/;++// from './x' | import './x' | import('./x') — the specifier homes in a .d.ts.+const SPECIFIER =+ /(\bfrom\s*|\bimport\s+|\bimport\(\s*)(["'])(\.\.?(?:\/[^"']*)?)\2/g;++const COMMENT_LINE = /^\s*(?:\*|\/\/|\/\*)/;++/**+ * Return the fully specified form of `specifier`, as written in a+ * declaration file inside `dir`, or the specifier itself when no+ * declaration target exists.+ */+export function resolveSpecifier(specifier, dir) {+ if (FULLY_SPECIFIED.test(specifier)) return specifier;+ if (specifier === '.' || specifier === '..') {+ return fs.existsSync(path.join(dir, specifier, 'index.d.ts'))+ ? `${specifier}/index.js`+ : specifier;+ }+ if (fs.existsSync(path.join(dir, `${specifier}.d.ts`))) {+ return `${specifier}.js`;+ }+ if (fs.existsSync(path.join(dir, specifier, 'index.d.ts'))) {+ return `${specifier}/index.js`;+ }+ return specifier;+}++/** Rewrite the relative specifiers in one declaration file's source. */+export function rewriteSource(source, dir) {+ return source+ .split('\n')+ .map(line =>+ COMMENT_LINE.test(line)+ ? line+ : line.replace(+ SPECIFIER,+ (match, prefix, quote, specifier) =>+ `${prefix}${quote}${resolveSpecifier(specifier, dir)}${quote}`,+ ),+ )+ .join('\n');+}++function walk(dir) {+ const results = [];+ for (const entry of fs.readdirSync(dir, {withFileTypes: true})) {+ const full = path.join(dir, entry.name);+ if (entry.isDirectory()) {+ results.push(...walk(full));+ } else if (entry.name.endsWith('.d.ts')) {+ results.push(full);+ }+ }+ return results;+}++/** Rewrite every declaration file under `distDir`; return the count changed. */+export function addDeclarationExtensions(distDir) {+ let changed = 0;+ for (const file of walk(distDir)) {+ const source = fs.readFileSync(file, 'utf-8');+ const rewritten = rewriteSource(source, path.dirname(file));+ if (rewritten !== source) {+ fs.writeFileSync(file, rewritten);+ changed++;+ }+ }+ return changed;+}++// Run as a script, but stay importable for unit tests.+if (process.argv[1] === fileURLToPath(import.meta.url)) {+ const distDir = path.resolve(process.cwd(), 'dist');+ const changed = addDeclarationExtensions(distDir);+ console.log(+ `✅ ${changed} declaration file(s) now use fully specified relative specifiers.`,+ );+}diff --git a/scripts/add-declaration-extensions.test.mjs b/scripts/add-declaration-extensions.test.mjsnew file mode 100644index 0000000000..5a2ed49b82--- /dev/null+++ b/scripts/add-declaration-extensions.test.mjs@@ -0,0 +1,171 @@+// Copyright (c) Meta Platforms, Inc. and affiliates.++/**+ * @file Verifies the declaration specifier rewrite.+ * @input A temporary package whose dist holds emitted .d.ts files.+ * @output Confirms relative specifiers become fully specified declaration+ * paths that strict NodeNext consumers resolve (#7702).+ * @position Regression coverage for the build step that runs after the tsc+ * declaration emit.+ */++import {execFileSync} from 'node:child_process';+import {+ mkdirSync,+ mkdtempSync,+ readFileSync,+ rmSync,+ writeFileSync,+} from 'node:fs';+import {tmpdir} from 'node:os';+import path from 'node:path';+import {fileURLToPath} from 'node:url';+import {afterAll, beforeAll, describe, expect, it} from 'vitest';+import {rewriteSource} from './add-declaration-extensions.mjs';+import {findOffenders} from './check-fully-specified.mjs';++const SCRIPT = fileURLToPath(+ new URL('./add-declaration-extensions.mjs', import.meta.url),+);++/** Write `files` (relative path → contents) under `root`. */+function writeTree(root, files) {+ for (const [file, contents] of Object.entries(files)) {+ mkdirSync(path.dirname(path.join(root, file)), {recursive: true});+ writeFileSync(path.join(root, file), contents);+ }+}++describe('rewriteSource', () => {+ let dist;++ beforeAll(() => {+ dist = mkdtempSync(path.join(tmpdir(), 'astryx-dts-extensions-'));+ writeTree(dist, {+ 'index.d.ts': '',+ 'Button/index.d.ts': '',+ 'Selector/index.d.ts': '',+ 'Selector/Selector.d.ts': '',+ 'Selector/hooks.d.ts': '',+ 'Selector/hooks/index.d.ts': '',+ 'theme/tokens.stylex.d.ts': '',+ 'theme/theme.css.d.ts': '',+ });+ });++ afterAll(() => {+ rmSync(dist, {force: true, recursive: true});+ });++ const rewrite = source => rewriteSource(source, path.join(dist, 'Selector'));++ it('adds .js to a specifier that names a declaration file', () => {+ expect(rewrite(`export { Selector } from './Selector';`)).toBe(+ `export { Selector } from './Selector.js';`,+ );+ });++ it('adds /index.js to a specifier that names a directory', () => {+ expect(rewrite(`import { type ButtonVariant } from '../Button';`)).toBe(+ `import { type ButtonVariant } from '../Button/index.js';`,+ );+ });++ it('prefers the file when a file and a directory share a name', () => {+ expect(rewrite(`export * from './hooks';`)).toBe(+ `export * from './hooks.js';`,+ );+ });++ it("rewrites re-exports from '.' and '..'", () => {+ const nested = path.join(dist, 'Selector', 'hooks');+ expect(rewriteSource(`export * from '.';`, nested)).toBe(+ `export * from './index.js';`,+ );+ expect(rewrite(`export * from "..";`)).toBe(`export * from "../index.js";`);+ });++ it('rewrites inline import() types', () => {+ expect(+ rewrite(`export declare const p: import("./hooks/index").Hook<never>;`),+ ).toBe(`export declare const p: import("./hooks/index.js").Hook<never>;`);+ });++ it('keeps the .stylex part of a file name', () => {+ expect(rewrite(`import { vars } from '../theme/tokens.stylex';`)).toBe(+ `import { vars } from '../theme/tokens.stylex.js';`,+ );+ });++ it('leaves specifiers that are already fully specified or bare', () => {+ const source = [+ `import '../theme/theme.css';`,+ `export * from './Selector.js';`,+ `import type { ReactNode } from 'react';`,+ ].join('\n');+ expect(rewrite(source)).toBe(source);+ });++ it('does not resolve a specifier to a .css.d.ts declaration', () => {+ expect(rewrite(`import '../theme/theme';`)).toBe(+ `import '../theme/theme';`,+ );+ });++ it('leaves unresolvable specifiers for the fully-specified check', () => {+ expect(rewrite(`export * from './missing';`)).toBe(+ `export * from './missing';`,+ );+ });++ it('skips comment lines and handles multi-line exports and CRLF', () => {+ const source = [+ `/**`,+ ` * import { Selector } from './Selector';`,+ ` */`,+ `export type {`,+ ` SelectorProps,`,+ `} from './Selector';\r`,+ ].join('\n');+ expect(rewrite(source).split('\n')).toEqual([+ `/**`,+ ` * import { Selector } from './Selector';`,+ ` */`,+ `export type {`,+ ` SelectorProps,`,+ `} from './Selector.js';\r`,+ ]);+ });+});++it('rewrites a package dist so the fully-specified check passes', () => {+ const cwd = mkdtempSync(path.join(tmpdir(), 'astryx-dts-extensions-run-'));++ try {+ writeTree(cwd, {+ 'dist/index.d.ts': `export * from './Selector';\n`,+ 'dist/Selector/index.d.ts':+ `export { Selector } from './Selector';\n` ++ `export type { Option } from '../types';\n`,+ 'dist/Selector/Selector.d.ts': `export declare const Selector: () => null;\n`,+ 'dist/types.d.ts': `export type Option = string;\n`,+ 'dist/Selector/index.js': `export { Selector } from './Selector.js';\n`,+ });+ expect(findOffenders(path.join(cwd, 'dist')).offenders).toHaveLength(2);++ execFileSync(process.execPath, [SCRIPT], {cwd});++ expect(readFileSync(path.join(cwd, 'dist', 'index.d.ts'), 'utf-8')).toBe(+ `export * from './Selector/index.js';\n`,+ );+ expect(+ readFileSync(path.join(cwd, 'dist', 'Selector', 'index.d.ts'), 'utf-8'),+ ).toBe(+ `export { Selector } from './Selector.js';\n` ++ `export type { Option } from '../types.js';\n`,+ );+ expect(findOffenders(path.join(cwd, 'dist')).offenders).toEqual([]);+ } finally {+ rmSync(cwd, {force: true, recursive: true});+ }+});diff --git a/scripts/check-fully-specified.mjs b/scripts/check-fully-specified.mjsindex 6b25527222..502379313f 100644--- a/scripts/check-fully-specified.mjs+++ b/scripts/check-fully-specified.mjs@@ -8,14 +8,17 @@* These runtime files are consumed as ESM, where relative specifiers need an* explicit extension — strict-ESM consumers (Node itself, Rspack, webpack's* `fullySpecified`) refuse to resolve './XDSButton' where './XDSButton.js' is- * required. Different packages use different compilers to produce those- * specifiers; this guard makes sure nothing slips into the artifact again- * (#4569: dynamic `import()` specifiers did exactly that).+ * required. In a `"type": "module"` package the .d.ts files follow the same+ * rule for TypeScript consumers on NodeNext resolution (#7702). Declarations+ * of a CommonJS package resolve without extensions, so they are not scanned;+ * if such a package becomes ESM, this check fails its build until it runs+ * add-declaration-extensions.mjs. Different packages use different compilers+ * to produce those specifiers; this guard makes sure nothing slips into the+ * artifact again (#4569: dynamic `import()` specifiers did exactly that).** Like check-no-dev-jsx.mjs this is a textual scan, not a parse. Comment* lines are skipped: dist keeps some JSDoc comments whose usage examples- * legitimately mention extensionless specifiers. Only runtime files are- * scanned — the .d.ts surface resolves through TypeScript, not Node.+ * legitimately mention extensionless specifiers.** Usage: node <repo-root>/scripts/check-fully-specified.mjs (run from a* package root, after the package's dist has been built; the relative depth@@ -35,10 +38,11 @@ const FULLY_SPECIFIED = /\.(?:js|mjs|cjs|json|css)$/;// import('./x') (dynamic import)// import(`./x`) (no-substitution template — a static specifier in// disguise; templates with `${` stay computed and exempt)+// A bare '.' or '..' is a directory import, so it is relative too.const SPECIFIER_PATTERNS = [- /\bfrom\s*["'](\.\.?\/[^"']*)["']/g,- /\bimport\s+["'](\.\.?\/[^"']*)["']/g,- /\bimport\(\s*["'](\.\.?\/[^"']*)["']\s*\)/g,+ /\bfrom\s*["'](\.\.?(?:\/[^"']*)?)["']/g,+ /\bimport\s+["'](\.\.?(?:\/[^"']*)?)["']/g,+ /\bimport\(\s*["'](\.\.?(?:\/[^"']*)?)["']\s*\)/g,/\bimport\(\s*`(\.\.?\/[^`$]*)`\s*\)/g,];@@ -62,13 +66,16 @@ export function scanSource(source) {return offenders;}-function walk(dir) {+function walk(dir, declarations) {const results = [];for (const entry of fs.readdirSync(dir, {withFileTypes: true})) {const full = path.join(dir, entry.name);if (entry.isDirectory()) {- results.push(...walk(full));- } else if (/\.(js|mjs|cjs)$/.test(entry.name)) {+ results.push(...walk(full, declarations));+ } else if (+ /\.(js|mjs|cjs)$/.test(entry.name) ||+ (declarations && entry.name.endsWith('.d.ts'))+ ) {results.push(full);}}@@ -76,11 +83,11 @@ function walk(dir) {}/**- * Scan every runtime file under `distDir`; return- * {checked, offenders: [{file, specifiers}]}.+ * Scan every runtime file under `distDir`, and every .d.ts file unless+ * `declarations` is false; return {checked, offenders: [{file, specifiers}]}.*/-export function findOffenders(distDir) {- const files = walk(distDir);+export function findOffenders(distDir, {declarations = true} = {}) {+ const files = walk(distDir, declarations);const offenders = [];for (const file of files) {const specifiers = scanSource(fs.readFileSync(file, 'utf-8'));@@ -91,6 +98,18 @@ export function findOffenders(distDir) {return {checked: files.length, offenders};}+/** Whether the package at `packageDir` declares `"type": "module"`. */+export function isModulePackage(packageDir) {+ try {+ const packageJson = JSON.parse(+ fs.readFileSync(path.join(packageDir, 'package.json'), 'utf-8'),+ );+ return packageJson.type === 'module';+ } catch {+ return false;+ }+}+/*** Return remediation guidance for the package whose dist is being checked.*@@ -139,7 +158,9 @@ function main() {process.exit(1);}- const {checked, offenders} = findOffenders(distDir);+ const {checked, offenders} = findOffenders(distDir, {+ declarations: isModulePackage(process.cwd()),+ });if (offenders.length > 0) {console.error('❌ Extensionless relative specifiers in build output:\n');@@ -154,6 +175,13 @@ function main() {'extension. ESM loaders and strict-ESM bundlers cannot resolve ' +`them (see #4569).\n${failureGuidance(process.cwd())}`,);+ if (offenders.some(({file}) => file.endsWith('.d.ts'))) {+ console.error(+ 'For .d.ts files: run scripts/add-declaration-extensions.mjs right ' ++ 'after the tsc declaration emit, and check that every reported ' ++ 'specifier has a declaration to resolve to (see #7702).',+ );+ }process.exit(1);}diff --git a/scripts/check-fully-specified.test.mjs b/scripts/check-fully-specified.test.mjsindex d5c1873a3f..730141ce1f 100644--- a/scripts/check-fully-specified.test.mjs+++ b/scripts/check-fully-specified.test.mjs@@ -7,6 +7,7 @@* dynamic `import()` specifiers had none, breaking strict-ESM consumers).*/+import {spawnSync} from 'node:child_process';import fs from 'node:fs';import os from 'node:os';import path from 'node:path';@@ -125,10 +126,15 @@ describe('findOffenders', () => {path.join(distDir, 'Text', 'Text.js'),`const L = lazy(() => import('../Tooltip/Tooltip'));\n`,);- // Non-runtime files are not scanned.+ // Declarations are scanned too: NodeNext consumers need the extension+ // (#7702). Other non-runtime files are not scanned.fs.writeFileSync(path.join(distDir, 'Text', 'Text.d.ts'),- `export * from '../types';\n`,+ `export * from '../types';\nexport * from '.';\n`,+ );+ fs.writeFileSync(+ path.join(distDir, 'Text', 'Text.d.ts.map'),+ `{"sources":["../types"]}\n`,);});@@ -136,16 +142,18 @@ describe('findOffenders', () => {fs.rmSync(distDir, {recursive: true, force: true});});- it('reports offending runtime files with their bad specifiers', () => {- expect(findOffenders(distDir)).toEqual({- // clean.js + Text/Text.js — the .d.ts file must not be scanned.- checked: 2,- offenders: [- {- file: path.join('Text', 'Text.js'),- specifiers: ['../Tooltip/Tooltip'],- },- ],+ it('reports offending runtime and declaration files with their bad specifiers', () => {+ const {checked, offenders} = findOffenders(distDir);+ // clean.js + Text/Text.js + Text/Text.d.ts — the source map is not scanned.+ expect(checked).toBe(3);+ expect(offenders).toHaveLength(2);+ expect(offenders).toContainEqual({+ file: path.join('Text', 'Text.js'),+ specifiers: ['../Tooltip/Tooltip'],+ });+ expect(offenders).toContainEqual({+ file: path.join('Text', 'Text.d.ts'),+ specifiers: ['../types', '.'],});});@@ -175,6 +183,43 @@ describe('findOffenders', () => {});});+describe('declaration scan by package type', () => {+ const SCRIPT = path.join(ROOT, 'scripts', 'check-fully-specified.mjs');++ /** Run the check in a package of `type` whose only dist file is a .d.ts. */+ const runIn = type => {+ const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'fully-specified-pkg-'));+ try {+ fs.writeFileSync(+ path.join(dir, 'package.json'),+ JSON.stringify(type ? {name: 'example', type} : {name: 'example'}),+ );+ fs.mkdirSync(path.join(dir, 'dist'));+ fs.writeFileSync(+ path.join(dir, 'dist', 'index.d.ts'),+ `export * from './theme';\n`,+ );+ return spawnSync(process.execPath, [SCRIPT], {+ cwd: dir,+ encoding: 'utf-8',+ });+ } finally {+ fs.rmSync(dir, {recursive: true, force: true});+ }+ };++ it('passes extensionless declarations in a CommonJS package', () => {+ expect(runIn(undefined).status).toBe(0);+ });++ it('fails extensionless declarations in an ESM package', () => {+ const result = runIn('module');+ expect(result.status).toBe(1);+ expect(result.stderr).toContain('dist/index.d.ts: ./theme');+ expect(result.stderr).toContain('add-declaration-extensions.mjs');+ });+});+describe('failureGuidance', () => {it('points maintained themes at --icons-specifier', () => {const dir = fs.mkdtempSync(