From d9f4396df6d58bc252c8ad31be7472fb2e72e690 Mon Sep 17 00:00:00 2001 From: Andrew Branch Date: Mon, 26 Aug 2024 16:51:28 -0700 Subject: [PATCH] Use --experimental-transform-types --- .github/workflows/ci.yml | 2 +- .github/workflows/deploy-web.yml | 2 +- .github/workflows/version-or-publish.yml | 2 +- package.json | 5 ++- packages/cli/package.json | 3 +- packages/cli/src/getExitCode.ts | 4 +- packages/cli/src/index.ts | 12 +++--- packages/cli/src/readConfig.ts | 2 +- packages/cli/src/render/index.ts | 6 +-- packages/cli/src/render/typed.ts | 6 +-- packages/cli/test/snapshots.test.ts | 41 ++++++++++--------- packages/cli/test/tsconfig.json | 8 +--- packages/cli/tsconfig.json | 1 + packages/core/package.json | 16 +++++--- packages/core/src/checkPackage.ts | 14 +++---- packages/core/src/createPackage.ts | 2 +- packages/core/src/index.ts | 6 +-- .../internal/checks/cjsOnlyExportsDefault.ts | 2 +- .../internal/checks/entrypointResolutions.ts | 6 +-- .../checks/exportDefaultDisagreement.ts | 6 +-- packages/core/src/internal/checks/index.ts | 12 +++--- .../checks/internalResolutionError.ts | 4 +- .../internal/checks/moduleKindDisagreement.ts | 2 +- .../internal/checks/unexpectedModuleSyntax.ts | 2 +- packages/core/src/internal/defineCheck.ts | 6 +-- .../core/src/internal/getEntrypointInfo.ts | 17 ++++---- .../core/src/internal/multiCompilerHost.ts | 4 +- packages/core/src/problems.ts | 4 +- packages/core/src/utils.ts | 2 +- packages/core/test/getProbableExports.test.ts | 2 +- .../exportDefaultDisagreement.test.ts | 10 ++--- packages/core/test/snapshots.test.ts | 8 ++-- packages/core/test/tsconfig.json | 7 +--- packages/core/tsconfig.json | 1 + packages/web/vite.config.js | 16 ++++---- pnpm-lock.yaml | 11 ++++- tsconfig.test.json | 10 +++++ 37 files changed, 142 insertions(+), 122 deletions(-) create mode 100644 tsconfig.test.json diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2bcf9b3..3dbe63d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,7 +12,7 @@ jobs: fetch-depth: 1 - uses: actions/setup-node@v3 with: - node-version: 21 + node-version: 22 - uses: pnpm/action-setup@v2 with: version: latest diff --git a/.github/workflows/deploy-web.yml b/.github/workflows/deploy-web.yml index 6e3449e..376e112 100644 --- a/.github/workflows/deploy-web.yml +++ b/.github/workflows/deploy-web.yml @@ -12,7 +12,7 @@ jobs: fetch-depth: 1 - uses: actions/setup-node@v3 with: - node-version: 21 + node-version: 22 - uses: pnpm/action-setup@v2 with: version: latest diff --git a/.github/workflows/version-or-publish.yml b/.github/workflows/version-or-publish.yml index 88baa7e..9e302e8 100644 --- a/.github/workflows/version-or-publish.yml +++ b/.github/workflows/version-or-publish.yml @@ -20,7 +20,7 @@ jobs: fetch-depth: 1 - uses: actions/setup-node@v3 with: - node-version: 21 + node-version: 22 - uses: pnpm/action-setup@v2 with: version: latest diff --git a/package.json b/package.json index febf97d..229020a 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,7 @@ "build": "pnpm tsc && pnpm -r build", "format": "prettier --write \"**/*.{ts,json,css}\"", "test": "pnpm -r test", + "test-js": "pnpm tsc && pnpm -r test-js", "check-dts": "tsc -p tsconfig.check-dts.json", "start": "pnpm --filter @arethetypeswrong/web start", "version": "changeset version && pnpm install --lockfile-only" @@ -18,10 +19,10 @@ "devDependencies": { "@changesets/cli": "^2.27.1", "prettier": "^3.0.3", - "typescript": "5.6.1-rc" + "typescript": "npm:@typescript-deploys/pr-build@5.7.0-pr-59767-2" }, "engines": { - "node": ">=18", + "node": ">=22", "pnpm": ">=8" } } diff --git a/packages/cli/package.json b/packages/cli/package.json index b848154..050bd55 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -40,7 +40,8 @@ "tsc": "tsc -b", "local:install": "npm install -g .", "local:uninstall": "npm uninstall -g @arethetypeswrong/cli", - "test": "tsc -b test && node --test 'test/dist/**/*.test.js'", + "test": "node --experimental-transform-types --conditions=@arethetypeswrong/source --test 'test/**/*.test.ts'", + "test-js": "node --experimental-transform-types --test 'test/**/*.test.ts'", "prepack": "pnpm tsc" }, "type": "module", diff --git a/packages/cli/src/getExitCode.ts b/packages/cli/src/getExitCode.ts index 61078c4..711e694 100644 --- a/packages/cli/src/getExitCode.ts +++ b/packages/cli/src/getExitCode.ts @@ -1,6 +1,6 @@ import type { CheckResult } from "@arethetypeswrong/core"; -import { problemFlags } from "./problemUtils.js"; -import type { RenderOptions } from "./render/index.js"; +import { problemFlags } from "./problemUtils.ts"; +import type { RenderOptions } from "./render/index.ts"; export function getExitCode(analysis: CheckResult, opts?: RenderOptions): number { if (!analysis.types) { diff --git a/packages/cli/src/index.ts b/packages/cli/src/index.ts index 984e071..7648104 100644 --- a/packages/cli/src/index.ts +++ b/packages/cli/src/index.ts @@ -10,11 +10,11 @@ import { readFile, stat, unlink } from "fs/promises"; import { createRequire } from "module"; import path from "path"; import readline from "readline"; -import { problemFlags } from "./problemUtils.js"; -import { readConfig } from "./readConfig.js"; -import * as render from "./render/index.js"; +import { problemFlags } from "./problemUtils.ts"; +import { readConfig } from "./readConfig.ts"; +import * as render from "./render/index.ts"; import { major, minor } from "semver"; -import { getExitCode } from "./getExitCode.js"; +import { getExitCode } from "./getExitCode.ts"; const packageJson = createRequire(import.meta.url)("../package.json"); const version = packageJson.version; @@ -74,8 +74,8 @@ particularly ESM-related module resolution issues.`, .option("--exclude-entrypoints ", "Specify entrypoints to exclude from checking.") .option( "--entrypoints-legacy", - 'In packages without the `exports` field, every file is an entry point. Specifying this option ' + - 'only takes effect when no entrypoints are automatically detected, or explicitly provided with other options.' + "In packages without the `exports` field, every file is an entry point. Specifying this option " + + "only takes effect when no entrypoints are automatically detected, or explicitly provided with other options.", ) .addOption( new Option("--ignore-rules ", "Specify rules to ignore").choices(Object.values(problemFlags)).default([]), diff --git a/packages/cli/src/readConfig.ts b/packages/cli/src/readConfig.ts index aee1d17..30637c1 100644 --- a/packages/cli/src/readConfig.ts +++ b/packages/cli/src/readConfig.ts @@ -1,6 +1,6 @@ import { Command } from "commander"; import { readFile } from "fs/promises"; -import { problemFlags } from "./problemUtils.js"; +import { problemFlags } from "./problemUtils.ts"; export async function readConfig(program: Command, alternate = ".attw.json") { try { diff --git a/packages/cli/src/render/index.ts b/packages/cli/src/render/index.ts index 955c11b..d60ad1a 100644 --- a/packages/cli/src/render/index.ts +++ b/packages/cli/src/render/index.ts @@ -1,4 +1,4 @@ -import type { problemFlags } from "../problemUtils.js"; +import type { problemFlags } from "../problemUtils.ts"; export type Format = "auto" | "table" | "table-flipped" | "ascii" | "json"; export interface RenderOptions { @@ -9,5 +9,5 @@ export interface RenderOptions { emoji?: boolean; } -export * from "./typed.js"; -export * from "./untyped.js"; +export * from "./typed.ts"; +export * from "./untyped.ts"; diff --git a/packages/cli/src/render/typed.ts b/packages/cli/src/render/typed.ts index 28cca6d..ad55700 100644 --- a/packages/cli/src/render/typed.ts +++ b/packages/cli/src/render/typed.ts @@ -5,9 +5,9 @@ import chalk from "chalk"; import Table, { type GenericTable, type HorizontalTableRow } from "cli-table3"; import { marked } from "marked"; import TerminalRenderer from "marked-terminal"; -import { moduleKinds, problemFlags, resolutionKinds } from "../problemUtils.js"; -import { asciiTable } from "./asciiTable.js"; -import type { RenderOptions } from "./index.js"; +import { moduleKinds, problemFlags, resolutionKinds } from "../problemUtils.ts"; +import { asciiTable } from "./asciiTable.ts"; +import type { RenderOptions } from "./index.ts"; export async function typed( analysis: core.Analysis, diff --git a/packages/cli/test/snapshots.test.ts b/packages/cli/test/snapshots.test.ts index 72745e5..f04812e 100644 --- a/packages/cli/test/snapshots.test.ts +++ b/packages/cli/test/snapshots.test.ts @@ -1,9 +1,9 @@ -import { access, readFile, writeFile } from "fs/promises"; -import { execSync, type SpawnSyncReturns } from "child_process"; import assert from "node:assert"; +import { spawnSync } from "node:child_process"; +import { access, readFile, writeFile } from "node:fs/promises"; import { after, describe, test } from "node:test"; -const attw = `node ${new URL("../../dist/index.js", import.meta.url).pathname}`; +const attw = new URL("../src/index.ts", import.meta.url).pathname; const updateSnapshots = process.env.UPDATE_SNAPSHOTS || process.env.U; const testFilter = (process.env.TEST_FILTER || process.env.T)?.toLowerCase(); @@ -34,11 +34,11 @@ const tests = [ [ "big.js@6.2.1.tgz", - `--definitely-typed ${new URL("../../../core/test/fixtures/@types__big.js@6.2.0.tgz", import.meta.url).pathname}`, + `--definitely-typed ${new URL("../../core/test/fixtures/@types__big.js@6.2.0.tgz", import.meta.url).pathname}`, ], [ "react@18.2.0.tgz", - `--definitely-typed ${new URL("../../../core/test/fixtures/@types__react@18.2.21.tgz", import.meta.url).pathname}`, + `--definitely-typed ${new URL("../../core/test/fixtures/@types__react@18.2.21.tgz", import.meta.url).pathname}`, ], ["eslint-module-utils@2.8.1.tgz", "--entrypoints-legacy --ignore-rules=cjs-only-exports-default"], @@ -68,21 +68,22 @@ describe("snapshots", async () => { } test(fixture, async () => { - const tarballPath = new URL(`../../../core/test/fixtures/${tarball}`, import.meta.url).pathname; - let stdout; - let stderr = ""; - let exitCode = 0; - try { - stdout = execSync(`${attw} ${tarballPath} ${options ?? defaultOpts}`, { + const tarballPath = new URL(`../../core/test/fixtures/${tarball}`, import.meta.url).pathname; + const { + stdout, + stderr, + status = 1, + } = spawnSync( + process.execPath, + [...process.execArgv, attw, tarballPath, ...(options ?? defaultOpts).split(" ")], + { encoding: "utf8", - env: { ...process.env, FORCE_COLOR: "0" }, - }); - } catch (error) { - stdout = (error as SpawnSyncReturns).stdout; - stderr = (error as SpawnSyncReturns).stderr; - exitCode = (error as SpawnSyncReturns).status ?? 1; - } - const snapshotURL = new URL(`../snapshots/${fixture}.md`, import.meta.url); + stdio: "pipe", + env: { ...process.env, FORCE_COLOR: "0", NODE_OPTIONS: "--no-warnings" }, + }, + ); + + const snapshotURL = new URL(`snapshots/${fixture}.md`, import.meta.url); // prettier-ignore const expectedSnapshot = [ `# ${fixture}`, @@ -94,7 +95,7 @@ describe("snapshots", async () => { "", "```", "", - `Exit code: ${exitCode}`, + `Exit code: ${status}`, ].join("\n"); if ( diff --git a/packages/cli/test/tsconfig.json b/packages/cli/test/tsconfig.json index 29c17b3..16e9c96 100644 --- a/packages/cli/test/tsconfig.json +++ b/packages/cli/test/tsconfig.json @@ -1,11 +1,5 @@ { - "extends": "../../../tsconfig.base.json", - "compilerOptions": { - "lib": ["es2019"], - "module": "nodenext", - "outDir": "dist", - "types": ["node"] - }, + "extends": "../../../tsconfig.test.json", "references": [ { "path": ".." diff --git a/packages/cli/tsconfig.json b/packages/cli/tsconfig.json index c787e53..3a1641d 100644 --- a/packages/cli/tsconfig.json +++ b/packages/cli/tsconfig.json @@ -2,6 +2,7 @@ "extends": "../../tsconfig.base.json", "compilerOptions": { "module": "nodenext", + "rewriteRelativeImportExtensions": true, "rootDir": "src", "types": ["node", "ts-expose-internals"], "outDir": "./dist", diff --git a/packages/core/package.json b/packages/core/package.json index b45eed0..855a41e 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -19,29 +19,33 @@ }, "scripts": { "tsc": "tsc", - "test": "tsc -b test && node --test 'test/dist/**/*.test.js'", + "test": "node --experimental-transform-types --conditions=@arethetypeswrong/source --test 'test/**/*.test.ts'", + "test-js": "node --experimental-transform-types --test 'test/**/*.test.ts'", "snapshot": "node scripts/createSnapshotFixture.js", "prepack": "pnpm tsc" }, "type": "module", "imports": { - "#internal/*": "./dist/internal/*" + "#internal/*": { + "@arethetypeswrong/source": "./src/internal/*.ts", + "default": "./dist/internal/*.js" + } }, "exports": { ".": { - "development": "./src/index.ts", + "@arethetypeswrong/source": "./src/index.ts", "default": "./dist/index.js" }, "./types": { - "development": "./src/types.ts", + "@arethetypeswrong/source": "./src/types.ts", "default": "./dist/types.js" }, "./utils": { - "development": "./src/utils.ts", + "@arethetypeswrong/source": "./src/utils.ts", "default": "./dist/utils.js" }, "./problems": { - "development": "./src/problems.ts", + "@arethetypeswrong/source": "./src/problems.ts", "default": "./dist/problems.js" }, "./versions": { diff --git a/packages/core/src/checkPackage.ts b/packages/core/src/checkPackage.ts index 028355b..f44f555 100644 --- a/packages/core/src/checkPackage.ts +++ b/packages/core/src/checkPackage.ts @@ -1,7 +1,7 @@ -import type { Package } from "./createPackage.js"; -import checks from "./internal/checks/index.js"; -import type { AnyCheck, CheckDependenciesContext } from "./internal/defineCheck.js"; -import { createCompilerHosts } from "./internal/multiCompilerHost.js"; +import type { Package } from "./createPackage.ts"; +import checks from "./internal/checks/index.ts"; +import type { AnyCheck, CheckDependenciesContext } from "./internal/defineCheck.ts"; +import { createCompilerHosts } from "./internal/multiCompilerHost.ts"; import type { AnalysisTypes, CheckResult, @@ -9,9 +9,9 @@ import type { Problem, ProgramInfo, ResolutionOption, -} from "./types.js"; -import { getResolutionOption, visitResolutions } from "./utils.js"; -import { getEntrypointInfo, getModuleKinds, getBuildTools } from "./internal/getEntrypointInfo.js"; +} from "./types.ts"; +import { getResolutionOption, visitResolutions } from "./utils.ts"; +import { getEntrypointInfo, getModuleKinds, getBuildTools } from "./internal/getEntrypointInfo.ts"; export interface CheckPackageOptions { /** diff --git a/packages/core/src/createPackage.ts b/packages/core/src/createPackage.ts index 40851d3..5b46ef4 100644 --- a/packages/core/src/createPackage.ts +++ b/packages/core/src/createPackage.ts @@ -2,7 +2,7 @@ import { untar } from "@andrewbranch/untar.js"; import { Gunzip } from "fflate"; import { major, maxSatisfying, minor, valid, validRange } from "semver"; import ts from "typescript"; -import { parsePackageSpec, type ParsedPackageSpec } from "./utils.js"; +import { parsePackageSpec, type ParsedPackageSpec } from "./utils.ts"; export class Package { #files: Record = {}; diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts index 0c6f6ea..a96996b 100644 --- a/packages/core/src/index.ts +++ b/packages/core/src/index.ts @@ -1,3 +1,3 @@ -export * from "./checkPackage.js"; -export * from "./createPackage.js"; -export type * from "./types.js"; +export * from "./checkPackage.ts"; +export * from "./createPackage.ts"; +export type * from "./types.ts"; diff --git a/packages/core/src/internal/checks/cjsOnlyExportsDefault.ts b/packages/core/src/internal/checks/cjsOnlyExportsDefault.ts index 1c4c010..9a6b048 100644 --- a/packages/core/src/internal/checks/cjsOnlyExportsDefault.ts +++ b/packages/core/src/internal/checks/cjsOnlyExportsDefault.ts @@ -1,5 +1,5 @@ import ts from "typescript"; -import { defineCheck } from "../defineCheck.js"; +import { defineCheck } from "../defineCheck.ts"; export default defineCheck({ name: "CJSOnlyExportsDefault", diff --git a/packages/core/src/internal/checks/entrypointResolutions.ts b/packages/core/src/internal/checks/entrypointResolutions.ts index acb85db..8a5c729 100644 --- a/packages/core/src/internal/checks/entrypointResolutions.ts +++ b/packages/core/src/internal/checks/entrypointResolutions.ts @@ -1,7 +1,7 @@ import ts from "typescript"; -import type { Problem } from "../../types.js"; -import { resolvedThroughFallback } from "../../utils.js"; -import { defineCheck } from "../defineCheck.js"; +import type { Problem } from "../../types.ts"; +import { resolvedThroughFallback } from "../../utils.ts"; +import { defineCheck } from "../defineCheck.ts"; export default defineCheck({ name: "EntrypointResolutions", diff --git a/packages/core/src/internal/checks/exportDefaultDisagreement.ts b/packages/core/src/internal/checks/exportDefaultDisagreement.ts index df27860..91d9642 100644 --- a/packages/core/src/internal/checks/exportDefaultDisagreement.ts +++ b/packages/core/src/internal/checks/exportDefaultDisagreement.ts @@ -1,7 +1,7 @@ import ts from "typescript"; -import { defineCheck } from "../defineCheck.js"; -import { getProbableExports, type Export } from "../getProbableExports.js"; -import { getResolutionOption } from "../../utils.js"; +import { defineCheck } from "../defineCheck.ts"; +import { getProbableExports, type Export } from "../getProbableExports.ts"; +import { getResolutionOption } from "../../utils.ts"; const bindOptions: ts.CompilerOptions = { target: ts.ScriptTarget.Latest, diff --git a/packages/core/src/internal/checks/index.ts b/packages/core/src/internal/checks/index.ts index b7ec801..a3ac6dc 100644 --- a/packages/core/src/internal/checks/index.ts +++ b/packages/core/src/internal/checks/index.ts @@ -1,9 +1,9 @@ -import cjsOnlyExportsDefault from "./cjsOnlyExportsDefault.js"; -import entrypointResolutions from "./entrypointResolutions.js"; -import exportDefaultDisagreement from "./exportDefaultDisagreement.js"; -import internalResolutionError from "./internalResolutionError.js"; -import moduleKindDisagreement from "./moduleKindDisagreement.js"; -import unexpectedModuleSyntax from "./unexpectedModuleSyntax.js"; +import cjsOnlyExportsDefault from "./cjsOnlyExportsDefault.ts"; +import entrypointResolutions from "./entrypointResolutions.ts"; +import exportDefaultDisagreement from "./exportDefaultDisagreement.ts"; +import internalResolutionError from "./internalResolutionError.ts"; +import moduleKindDisagreement from "./moduleKindDisagreement.ts"; +import unexpectedModuleSyntax from "./unexpectedModuleSyntax.ts"; export default [ entrypointResolutions, diff --git a/packages/core/src/internal/checks/internalResolutionError.ts b/packages/core/src/internal/checks/internalResolutionError.ts index 4d09862..8a14ca1 100644 --- a/packages/core/src/internal/checks/internalResolutionError.ts +++ b/packages/core/src/internal/checks/internalResolutionError.ts @@ -1,6 +1,6 @@ import ts from "typescript"; -import { defineCheck } from "../defineCheck.js"; -import type { InternalResolutionErrorProblem } from "../../types.js"; +import { defineCheck } from "../defineCheck.ts"; +import type { InternalResolutionErrorProblem } from "../../types.ts"; export default defineCheck({ name: "InternalResolutionError", diff --git a/packages/core/src/internal/checks/moduleKindDisagreement.ts b/packages/core/src/internal/checks/moduleKindDisagreement.ts index 78e514d..f79de0e 100644 --- a/packages/core/src/internal/checks/moduleKindDisagreement.ts +++ b/packages/core/src/internal/checks/moduleKindDisagreement.ts @@ -1,5 +1,5 @@ import ts from "typescript"; -import { defineCheck } from "../defineCheck.js"; +import { defineCheck } from "../defineCheck.ts"; export default defineCheck({ name: "ModuleKindDisagreement", diff --git a/packages/core/src/internal/checks/unexpectedModuleSyntax.ts b/packages/core/src/internal/checks/unexpectedModuleSyntax.ts index dfc6f1a..5375533 100644 --- a/packages/core/src/internal/checks/unexpectedModuleSyntax.ts +++ b/packages/core/src/internal/checks/unexpectedModuleSyntax.ts @@ -1,5 +1,5 @@ import ts from "typescript"; -import { defineCheck } from "../defineCheck.js"; +import { defineCheck } from "../defineCheck.ts"; export default defineCheck({ name: "UnexpectedModuleSyntax", diff --git a/packages/core/src/internal/defineCheck.ts b/packages/core/src/internal/defineCheck.ts index 557714c..1d36fba 100644 --- a/packages/core/src/internal/defineCheck.ts +++ b/packages/core/src/internal/defineCheck.ts @@ -1,6 +1,6 @@ -import type { Package } from "../createPackage.js"; -import type { CompilerHosts } from "./multiCompilerHost.js"; -import type { Analysis, Problem, ResolutionKind, ResolutionOption } from "../types.js"; +import type { Package } from "../createPackage.ts"; +import type { CompilerHosts } from "./multiCompilerHost.ts"; +import type { Analysis, Problem, ResolutionKind, ResolutionOption } from "../types.ts"; export interface CheckDependenciesContext extends CheckExecutionContext { subpath: string; diff --git a/packages/core/src/internal/getEntrypointInfo.ts b/packages/core/src/internal/getEntrypointInfo.ts index b91ba44..3e1cd95 100644 --- a/packages/core/src/internal/getEntrypointInfo.ts +++ b/packages/core/src/internal/getEntrypointInfo.ts @@ -1,6 +1,6 @@ import ts from "typescript"; -import type { Package } from "../createPackage.js"; -import { CompilerHostWrapper, type CompilerHosts } from "./multiCompilerHost.js"; +import type { Package } from "../createPackage.ts"; +import { CompilerHostWrapper, type CompilerHosts } from "./multiCompilerHost.ts"; import type { BuildTool, EntrypointInfo, @@ -9,9 +9,9 @@ import type { Resolution, ResolutionKind, ResolutionOption, -} from "../types.js"; -import { allBuildTools, getResolutionKinds } from "../utils.js"; -import type { CheckPackageOptions } from "../checkPackage.js"; +} from "../types.ts"; +import { allBuildTools, getResolutionKinds } from "../utils.ts"; +import type { CheckPackageOptions } from "../checkPackage.ts"; const extensions = new Set([".jsx", ".tsx", ".js", ".ts", ".mjs", ".cjs", ".mts", ".cjs"]); @@ -24,9 +24,10 @@ function getEntrypoints(fs: Package, exportsObject: unknown, options: CheckPacka const proxies = getProxyDirectories(rootDir, fs); if (proxies.length === 0) { if (options?.entrypointsLegacy) { - return fs.listFiles() - .filter(f => !ts.isDeclarationFileName(f) && extensions.has(f.slice(f.lastIndexOf(".")))) - .map(f => "." + f.slice(rootDir.length)); + return fs + .listFiles() + .filter((f) => !ts.isDeclarationFileName(f) && extensions.has(f.slice(f.lastIndexOf(".")))) + .map((f) => "." + f.slice(rootDir.length)); } return ["."]; } diff --git a/packages/core/src/internal/multiCompilerHost.ts b/packages/core/src/internal/multiCompilerHost.ts index ff77c03..5ba7d46 100644 --- a/packages/core/src/internal/multiCompilerHost.ts +++ b/packages/core/src/internal/multiCompilerHost.ts @@ -1,6 +1,6 @@ import ts from "typescript"; -import type { ModuleKind } from "../types.js"; -import type { Package } from "../createPackage.js"; +import type { ModuleKind } from "../types.ts"; +import type { Package } from "../createPackage.ts"; export interface ResolveModuleNameResult { resolution: ts.ResolvedModuleWithFailedLookupLocations; diff --git a/packages/core/src/problems.ts b/packages/core/src/problems.ts index c2a5a3c..3fc10b7 100644 --- a/packages/core/src/problems.ts +++ b/packages/core/src/problems.ts @@ -1,5 +1,5 @@ -import type { Analysis, Problem, ProblemKind, ResolutionKind, ResolutionOption } from "./types.js"; -import { getResolutionKinds } from "./utils.js"; +import type { Analysis, Problem, ProblemKind, ResolutionKind, ResolutionOption } from "./types.ts"; +import { getResolutionKinds } from "./utils.ts"; export interface ProblemKindInfo { title: string; diff --git a/packages/core/src/utils.ts b/packages/core/src/utils.ts index 4105074..9f09284 100644 --- a/packages/core/src/utils.ts +++ b/packages/core/src/utils.ts @@ -10,7 +10,7 @@ import type { ProblemKind, ResolutionKind, ResolutionOption, -} from "./types.js"; +} from "./types.ts"; export const allResolutionOptions: ResolutionOption[] = ["node10", "node16", "bundler"]; export const allResolutionKinds: ResolutionKind[] = ["node10", "node16-cjs", "node16-esm", "bundler"]; diff --git a/packages/core/test/getProbableExports.test.ts b/packages/core/test/getProbableExports.test.ts index dc0f6f9..b2e5289 100644 --- a/packages/core/test/getProbableExports.test.ts +++ b/packages/core/test/getProbableExports.test.ts @@ -1,4 +1,4 @@ -import { getProbableExports } from "#internal/getProbableExports.js"; +import { getProbableExports } from "#internal/getProbableExports"; import assert from "node:assert"; import { describe, test } from "node:test"; import ts from "typescript"; diff --git a/packages/core/test/problems/exportDefaultDisagreement.test.ts b/packages/core/test/problems/exportDefaultDisagreement.test.ts index 2d17b70..c9f21d9 100644 --- a/packages/core/test/problems/exportDefaultDisagreement.test.ts +++ b/packages/core/test/problems/exportDefaultDisagreement.test.ts @@ -1,9 +1,9 @@ -import check from "#internal/checks/exportDefaultDisagreement.js"; -import type { CheckExecutionContext } from "#internal/defineCheck.js"; -import { getEntrypointInfo } from "#internal/getEntrypointInfo.js"; -import { createCompilerHosts } from "#internal/multiCompilerHost.js"; +import check from "#internal/checks/exportDefaultDisagreement"; +import type { CheckExecutionContext } from "#internal/defineCheck"; +import { getEntrypointInfo } from "#internal/getEntrypointInfo"; +import { createCompilerHosts } from "#internal/multiCompilerHost"; import test, { describe } from "node:test"; -import { createTestPackage } from "../utils.js"; +import { createTestPackage } from "../utils.ts"; import assert from "node:assert"; function runCheck(ts: string, js: string) { diff --git a/packages/core/test/snapshots.test.ts b/packages/core/test/snapshots.test.ts index 3b5ccea..34dc10d 100644 --- a/packages/core/test/snapshots.test.ts +++ b/packages/core/test/snapshots.test.ts @@ -29,7 +29,7 @@ describe("snapshots", async () => { const errorPackages = ["Babel@0.0.1.tgz"]; - for (const fixture of fs.readdirSync(new URL("../fixtures", import.meta.url))) { + for (const fixture of fs.readdirSync(new URL("./fixtures", import.meta.url))) { if ( fixture === ".DS_Store" || fixture.startsWith("@types__") || @@ -39,9 +39,9 @@ describe("snapshots", async () => { } test(fixture, async () => { - const tarball = await readFile(new URL(`../fixtures/${fixture}`, import.meta.url)); + const tarball = await readFile(new URL(`./fixtures/${fixture}`, import.meta.url)); const typesTarball = typesPackages[fixture] - ? await readFile(new URL(`../fixtures/${typesPackages[fixture]}`, import.meta.url)) + ? await readFile(new URL(`./fixtures/${typesPackages[fixture]}`, import.meta.url)) : undefined; let analysis; try { @@ -56,7 +56,7 @@ describe("snapshots", async () => { throw error; } - const snapshotURL = new URL(`../snapshots/${fixture}.json`, import.meta.url); + const snapshotURL = new URL(`./snapshots/${fixture}.json`, import.meta.url); const expectedSnapshot = JSON.stringify(analysis, null, 2) + "\n"; if ( diff --git a/packages/core/test/tsconfig.json b/packages/core/test/tsconfig.json index 41a1fb7..49a8708 100644 --- a/packages/core/test/tsconfig.json +++ b/packages/core/test/tsconfig.json @@ -1,10 +1,7 @@ { - "extends": "../../../tsconfig.base.json", + "extends": "../../../tsconfig.test.json", "compilerOptions": { - "lib": ["es2019"], - "module": "nodenext", - "outDir": "dist", - "types": ["node", "ts-expose-internals"], + "types": ["node", "ts-expose-internals"] }, "references": [ { diff --git a/packages/core/tsconfig.json b/packages/core/tsconfig.json index 77bd8ab..377c707 100644 --- a/packages/core/tsconfig.json +++ b/packages/core/tsconfig.json @@ -8,6 +8,7 @@ // lib types imports this project. "lib": ["es2019", "webworker"], "module": "nodenext", + "rewriteRelativeImportExtensions": true, "outDir": "dist", "rootDir": "src", "types": ["ts-expose-internals"], diff --git a/packages/web/vite.config.js b/packages/web/vite.config.js index de9616b..2daa44c 100644 --- a/packages/web/vite.config.js +++ b/packages/web/vite.config.js @@ -1,18 +1,20 @@ import { defineConfig } from "vite"; -import { execSync } from 'child_process'; +import { execSync } from "child_process"; export default defineConfig(() => ({ - root: './src', + root: "./src", build: { - outDir: '../dist', + outDir: "../dist", emptyOutDir: true, }, + resolve: { + conditions: ["@arethetypeswrong/source"], + }, worker: { - format: 'es' + format: "es", }, define: { - COMMIT: JSON.stringify(execSync('git rev-parse HEAD').toString().trim().substring(0, 7)), - }, - optimizeDeps: { + COMMIT: JSON.stringify(execSync("git rev-parse HEAD").toString().trim().substring(0, 7)), }, + optimizeDeps: {}, })); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 55c7653..8da49c0 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -15,8 +15,8 @@ importers: specifier: ^3.0.3 version: 3.0.3 typescript: - specifier: 5.6.1-rc - version: 5.6.1-rc + specifier: npm:@typescript-deploys/pr-build@5.7.0-pr-59767-2 + version: '@typescript-deploys/pr-build@5.7.0-pr-59767-2' packages/cli: dependencies: @@ -694,6 +694,11 @@ packages: '@types/validate-npm-package-name@4.0.0': resolution: {integrity: sha512-RpO62vB2lkjEkyLbwTheA2+uwYmtVMWTr/kWRI++UAgVdZqNqdAuIQl/SxBCGeMKfdjWaXPbyhZbiCc4PAj+KA==} + '@typescript-deploys/pr-build@5.7.0-pr-59767-2': + resolution: {integrity: sha512-duxFwwpvzKDEHvahYEYmvAVZPFs0X+K7D0XKzSQWuxnhurcxx8T1r375N/B9IxR2GsUVTfIGayNXV5Sex0NF9w==} + engines: {node: '>=14.17'} + hasBin: true + abbrev@1.1.1: resolution: {integrity: sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==} @@ -2877,6 +2882,8 @@ snapshots: '@types/validate-npm-package-name@4.0.0': {} + '@typescript-deploys/pr-build@5.7.0-pr-59767-2': {} + abbrev@1.1.1: {} agent-base@6.0.2: diff --git a/tsconfig.test.json b/tsconfig.test.json new file mode 100644 index 0000000..6e0c7dc --- /dev/null +++ b/tsconfig.test.json @@ -0,0 +1,10 @@ +{ + "extends": "./tsconfig.base.json", + "compilerOptions": { + "lib": ["es2019"], + "module": "nodenext", + "allowImportingTsExtensions": true, + "noEmit": true, + "types": ["node"], + } +} \ No newline at end of file