Skip to content

Commit d3b1caf

Browse files
committed
Use --experimental-transform-types
1 parent 5905657 commit d3b1caf

37 files changed

+142
-122
lines changed

Diff for: .github/workflows/ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
fetch-depth: 1
1313
- uses: actions/setup-node@v3
1414
with:
15-
node-version: 21
15+
node-version: 22
1616
- uses: pnpm/action-setup@v2
1717
with:
1818
version: latest

Diff for: .github/workflows/deploy-web.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
fetch-depth: 1
1313
- uses: actions/setup-node@v3
1414
with:
15-
node-version: 21
15+
node-version: 22
1616
- uses: pnpm/action-setup@v2
1717
with:
1818
version: latest

Diff for: .github/workflows/version-or-publish.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
fetch-depth: 1
2121
- uses: actions/setup-node@v3
2222
with:
23-
node-version: 21
23+
node-version: 22
2424
- uses: pnpm/action-setup@v2
2525
with:
2626
version: latest

Diff for: package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,18 @@
1111
"build": "pnpm tsc && pnpm -r build",
1212
"format": "prettier --write \"**/*.{ts,json,css}\"",
1313
"test": "pnpm -r test",
14+
"test-js": "pnpm tsc && pnpm -r test-js",
1415
"check-dts": "tsc -p tsconfig.check-dts.json",
1516
"start": "pnpm --filter @arethetypeswrong/web start",
1617
"version": "changeset version && pnpm install --lockfile-only"
1718
},
1819
"devDependencies": {
1920
"@changesets/cli": "^2.27.1",
2021
"prettier": "^3.0.3",
21-
"typescript": "5.6.1-rc"
22+
"typescript": "npm:@typescript-deploys/[email protected]"
2223
},
2324
"engines": {
24-
"node": ">=18",
25+
"node": ">=22",
2526
"pnpm": ">=8"
2627
}
2728
}

Diff for: packages/cli/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@
4040
"tsc": "tsc -b",
4141
"local:install": "npm install -g .",
4242
"local:uninstall": "npm uninstall -g @arethetypeswrong/cli",
43-
"test": "tsc -b test && node --test 'test/dist/**/*.test.js'",
43+
"test": "node --experimental-transform-types --conditions=@arethetypeswrong/source --test 'test/**/*.test.ts'",
44+
"test-js": "node --experimental-transform-types --test 'test/**/*.test.ts'",
4445
"prepack": "pnpm tsc"
4546
},
4647
"type": "module",

Diff for: packages/cli/src/getExitCode.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { CheckResult } from "@arethetypeswrong/core";
2-
import { problemFlags } from "./problemUtils.js";
3-
import type { RenderOptions } from "./render/index.js";
2+
import { problemFlags } from "./problemUtils.ts";
3+
import type { RenderOptions } from "./render/index.ts";
44

55
export function getExitCode(analysis: CheckResult, opts?: RenderOptions): number {
66
if (!analysis.types) {

Diff for: packages/cli/src/index.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ import { readFile, stat, unlink } from "fs/promises";
1010
import { createRequire } from "module";
1111
import path from "path";
1212
import readline from "readline";
13-
import { problemFlags } from "./problemUtils.js";
14-
import { readConfig } from "./readConfig.js";
15-
import * as render from "./render/index.js";
13+
import { problemFlags } from "./problemUtils.ts";
14+
import { readConfig } from "./readConfig.ts";
15+
import * as render from "./render/index.ts";
1616
import { major, minor } from "semver";
17-
import { getExitCode } from "./getExitCode.js";
17+
import { getExitCode } from "./getExitCode.ts";
1818

1919
const packageJson = createRequire(import.meta.url)("../package.json");
2020
const version = packageJson.version;
@@ -74,8 +74,8 @@ particularly ESM-related module resolution issues.`,
7474
.option("--exclude-entrypoints <entrypoints...>", "Specify entrypoints to exclude from checking.")
7575
.option(
7676
"--entrypoints-legacy",
77-
'In packages without the `exports` field, every file is an entry point. Specifying this option ' +
78-
'only takes effect when no entrypoints are automatically detected, or explicitly provided with other options.'
77+
"In packages without the `exports` field, every file is an entry point. Specifying this option " +
78+
"only takes effect when no entrypoints are automatically detected, or explicitly provided with other options.",
7979
)
8080
.addOption(
8181
new Option("--ignore-rules <rules...>", "Specify rules to ignore").choices(Object.values(problemFlags)).default([]),

Diff for: packages/cli/src/readConfig.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Command } from "commander";
22
import { readFile } from "fs/promises";
3-
import { problemFlags } from "./problemUtils.js";
3+
import { problemFlags } from "./problemUtils.ts";
44

55
export async function readConfig(program: Command, alternate = ".attw.json") {
66
try {

Diff for: packages/cli/src/render/index.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { problemFlags } from "../problemUtils.js";
1+
import type { problemFlags } from "../problemUtils.ts";
22

33
export type Format = "auto" | "table" | "table-flipped" | "ascii" | "json";
44
export interface RenderOptions {
@@ -9,5 +9,5 @@ export interface RenderOptions {
99
emoji?: boolean;
1010
}
1111

12-
export * from "./typed.js";
13-
export * from "./untyped.js";
12+
export * from "./typed.ts";
13+
export * from "./untyped.ts";

Diff for: packages/cli/src/render/typed.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ import chalk from "chalk";
55
import Table, { type GenericTable, type HorizontalTableRow } from "cli-table3";
66
import { marked } from "marked";
77
import TerminalRenderer from "marked-terminal";
8-
import { moduleKinds, problemFlags, resolutionKinds } from "../problemUtils.js";
9-
import { asciiTable } from "./asciiTable.js";
10-
import type { RenderOptions } from "./index.js";
8+
import { moduleKinds, problemFlags, resolutionKinds } from "../problemUtils.ts";
9+
import { asciiTable } from "./asciiTable.ts";
10+
import type { RenderOptions } from "./index.ts";
1111

1212
export async function typed(
1313
analysis: core.Analysis,

Diff for: packages/cli/test/snapshots.test.ts

+21-20
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import { access, readFile, writeFile } from "fs/promises";
2-
import { execSync, type SpawnSyncReturns } from "child_process";
31
import assert from "node:assert";
2+
import { spawnSync } from "node:child_process";
3+
import { access, readFile, writeFile } from "node:fs/promises";
44
import { after, describe, test } from "node:test";
55

6-
const attw = `node ${new URL("../../dist/index.js", import.meta.url).pathname}`;
6+
const attw = new URL("../src/index.ts", import.meta.url).pathname;
77
const updateSnapshots = process.env.UPDATE_SNAPSHOTS || process.env.U;
88
const testFilter = (process.env.TEST_FILTER || process.env.T)?.toLowerCase();
99

@@ -34,11 +34,11 @@ const tests = [
3434

3535
[
3636
37-
`--definitely-typed ${new URL("../../../core/test/fixtures/@[email protected]", import.meta.url).pathname}`,
37+
`--definitely-typed ${new URL("../../core/test/fixtures/@[email protected]", import.meta.url).pathname}`,
3838
],
3939
[
4040
41-
`--definitely-typed ${new URL("../../../core/test/fixtures/@[email protected]", import.meta.url).pathname}`,
41+
`--definitely-typed ${new URL("../../core/test/fixtures/@[email protected]", import.meta.url).pathname}`,
4242
],
4343

4444
["[email protected]", "--entrypoints-legacy --ignore-rules=cjs-only-exports-default"],
@@ -68,21 +68,22 @@ describe("snapshots", async () => {
6868
}
6969

7070
test(fixture, async () => {
71-
const tarballPath = new URL(`../../../core/test/fixtures/${tarball}`, import.meta.url).pathname;
72-
let stdout;
73-
let stderr = "";
74-
let exitCode = 0;
75-
try {
76-
stdout = execSync(`${attw} ${tarballPath} ${options ?? defaultOpts}`, {
71+
const tarballPath = new URL(`../../core/test/fixtures/${tarball}`, import.meta.url).pathname;
72+
const {
73+
stdout,
74+
stderr,
75+
status = 1,
76+
} = spawnSync(
77+
process.execPath,
78+
[...process.execArgv, attw, tarballPath, ...(options ?? defaultOpts).split(" ")],
79+
{
7780
encoding: "utf8",
78-
env: { ...process.env, FORCE_COLOR: "0" },
79-
});
80-
} catch (error) {
81-
stdout = (error as SpawnSyncReturns<string>).stdout;
82-
stderr = (error as SpawnSyncReturns<string>).stderr;
83-
exitCode = (error as SpawnSyncReturns<string>).status ?? 1;
84-
}
85-
const snapshotURL = new URL(`../snapshots/${fixture}.md`, import.meta.url);
81+
stdio: "pipe",
82+
env: { ...process.env, FORCE_COLOR: "0", NODE_OPTIONS: "--no-warnings" },
83+
},
84+
);
85+
86+
const snapshotURL = new URL(`snapshots/${fixture}.md`, import.meta.url);
8687
// prettier-ignore
8788
const expectedSnapshot = [
8889
`# ${fixture}`,
@@ -94,7 +95,7 @@ describe("snapshots", async () => {
9495
"",
9596
"```",
9697
"",
97-
`Exit code: ${exitCode}`,
98+
`Exit code: ${status}`,
9899
].join("\n");
99100

100101
if (

Diff for: packages/cli/test/tsconfig.json

+1-7
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
{
2-
"extends": "../../../tsconfig.base.json",
3-
"compilerOptions": {
4-
"lib": ["es2019"],
5-
"module": "nodenext",
6-
"outDir": "dist",
7-
"types": ["node"]
8-
},
2+
"extends": "../../../tsconfig.test.json",
93
"references": [
104
{
115
"path": ".."

Diff for: packages/cli/tsconfig.json

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"extends": "../../tsconfig.base.json",
33
"compilerOptions": {
44
"module": "nodenext",
5+
"rewriteRelativeImportExtensions": true,
56
"rootDir": "src",
67
"types": ["node", "ts-expose-internals"],
78
"outDir": "./dist",

Diff for: packages/core/package.json

+10-6
Original file line numberDiff line numberDiff line change
@@ -19,29 +19,33 @@
1919
},
2020
"scripts": {
2121
"tsc": "tsc",
22-
"test": "tsc -b test && node --test 'test/dist/**/*.test.js'",
22+
"test": "node --experimental-transform-types --conditions=@arethetypeswrong/source --test 'test/**/*.test.ts'",
23+
"test-js": "node --experimental-transform-types --test 'test/**/*.test.ts'",
2324
"snapshot": "node scripts/createSnapshotFixture.js",
2425
"prepack": "pnpm tsc"
2526
},
2627
"type": "module",
2728
"imports": {
28-
"#internal/*": "./dist/internal/*"
29+
"#internal/*": {
30+
"@arethetypeswrong/source": "./src/internal/*.ts",
31+
"default": "./dist/internal/*.js"
32+
}
2933
},
3034
"exports": {
3135
".": {
32-
"development": "./src/index.ts",
36+
"@arethetypeswrong/source": "./src/index.ts",
3337
"default": "./dist/index.js"
3438
},
3539
"./types": {
36-
"development": "./src/types.ts",
40+
"@arethetypeswrong/source": "./src/types.ts",
3741
"default": "./dist/types.js"
3842
},
3943
"./utils": {
40-
"development": "./src/utils.ts",
44+
"@arethetypeswrong/source": "./src/utils.ts",
4145
"default": "./dist/utils.js"
4246
},
4347
"./problems": {
44-
"development": "./src/problems.ts",
48+
"@arethetypeswrong/source": "./src/problems.ts",
4549
"default": "./dist/problems.js"
4650
},
4751
"./versions": {

Diff for: packages/core/src/checkPackage.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
import type { Package } from "./createPackage.js";
2-
import checks from "./internal/checks/index.js";
3-
import type { AnyCheck, CheckDependenciesContext } from "./internal/defineCheck.js";
4-
import { createCompilerHosts } from "./internal/multiCompilerHost.js";
1+
import type { Package } from "./createPackage.ts";
2+
import checks from "./internal/checks/index.ts";
3+
import type { AnyCheck, CheckDependenciesContext } from "./internal/defineCheck.ts";
4+
import { createCompilerHosts } from "./internal/multiCompilerHost.ts";
55
import type {
66
AnalysisTypes,
77
CheckResult,
88
EntrypointResolutionAnalysis,
99
Problem,
1010
ProgramInfo,
1111
ResolutionOption,
12-
} from "./types.js";
13-
import { getResolutionOption, visitResolutions } from "./utils.js";
14-
import { getEntrypointInfo, getModuleKinds, getBuildTools } from "./internal/getEntrypointInfo.js";
12+
} from "./types.ts";
13+
import { getResolutionOption, visitResolutions } from "./utils.ts";
14+
import { getEntrypointInfo, getModuleKinds, getBuildTools } from "./internal/getEntrypointInfo.ts";
1515

1616
export interface CheckPackageOptions {
1717
/**

Diff for: packages/core/src/createPackage.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { untar } from "@andrewbranch/untar.js";
22
import { Gunzip } from "fflate";
33
import { major, maxSatisfying, minor, valid, validRange } from "semver";
44
import ts from "typescript";
5-
import { parsePackageSpec, type ParsedPackageSpec } from "./utils.js";
5+
import { parsePackageSpec, type ParsedPackageSpec } from "./utils.ts";
66

77
export class Package {
88
#files: Record<string, string | Uint8Array> = {};

Diff for: packages/core/src/index.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
export * from "./checkPackage.js";
2-
export * from "./createPackage.js";
3-
export type * from "./types.js";
1+
export * from "./checkPackage.ts";
2+
export * from "./createPackage.ts";
3+
export type * from "./types.ts";

Diff for: packages/core/src/internal/checks/cjsOnlyExportsDefault.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import ts from "typescript";
2-
import { defineCheck } from "../defineCheck.js";
2+
import { defineCheck } from "../defineCheck.ts";
33

44
export default defineCheck({
55
name: "CJSOnlyExportsDefault",

Diff for: packages/core/src/internal/checks/entrypointResolutions.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import ts from "typescript";
2-
import type { Problem } from "../../types.js";
3-
import { resolvedThroughFallback } from "../../utils.js";
4-
import { defineCheck } from "../defineCheck.js";
2+
import type { Problem } from "../../types.ts";
3+
import { resolvedThroughFallback } from "../../utils.ts";
4+
import { defineCheck } from "../defineCheck.ts";
55

66
export default defineCheck({
77
name: "EntrypointResolutions",

Diff for: packages/core/src/internal/checks/exportDefaultDisagreement.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import ts from "typescript";
2-
import { defineCheck } from "../defineCheck.js";
3-
import { getProbableExports, type Export } from "../getProbableExports.js";
4-
import { getResolutionOption } from "../../utils.js";
2+
import { defineCheck } from "../defineCheck.ts";
3+
import { getProbableExports, type Export } from "../getProbableExports.ts";
4+
import { getResolutionOption } from "../../utils.ts";
55

66
const bindOptions: ts.CompilerOptions = {
77
target: ts.ScriptTarget.Latest,

Diff for: packages/core/src/internal/checks/index.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import cjsOnlyExportsDefault from "./cjsOnlyExportsDefault.js";
2-
import entrypointResolutions from "./entrypointResolutions.js";
3-
import exportDefaultDisagreement from "./exportDefaultDisagreement.js";
4-
import internalResolutionError from "./internalResolutionError.js";
5-
import moduleKindDisagreement from "./moduleKindDisagreement.js";
6-
import unexpectedModuleSyntax from "./unexpectedModuleSyntax.js";
1+
import cjsOnlyExportsDefault from "./cjsOnlyExportsDefault.ts";
2+
import entrypointResolutions from "./entrypointResolutions.ts";
3+
import exportDefaultDisagreement from "./exportDefaultDisagreement.ts";
4+
import internalResolutionError from "./internalResolutionError.ts";
5+
import moduleKindDisagreement from "./moduleKindDisagreement.ts";
6+
import unexpectedModuleSyntax from "./unexpectedModuleSyntax.ts";
77

88
export default [
99
entrypointResolutions,

Diff for: packages/core/src/internal/checks/internalResolutionError.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import ts from "typescript";
2-
import { defineCheck } from "../defineCheck.js";
3-
import type { InternalResolutionErrorProblem } from "../../types.js";
2+
import { defineCheck } from "../defineCheck.ts";
3+
import type { InternalResolutionErrorProblem } from "../../types.ts";
44

55
export default defineCheck({
66
name: "InternalResolutionError",

Diff for: packages/core/src/internal/checks/moduleKindDisagreement.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import ts from "typescript";
2-
import { defineCheck } from "../defineCheck.js";
2+
import { defineCheck } from "../defineCheck.ts";
33

44
export default defineCheck({
55
name: "ModuleKindDisagreement",

Diff for: packages/core/src/internal/checks/unexpectedModuleSyntax.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import ts from "typescript";
2-
import { defineCheck } from "../defineCheck.js";
2+
import { defineCheck } from "../defineCheck.ts";
33

44
export default defineCheck({
55
name: "UnexpectedModuleSyntax",

Diff for: packages/core/src/internal/defineCheck.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import type { Package } from "../createPackage.js";
2-
import type { CompilerHosts } from "./multiCompilerHost.js";
3-
import type { Analysis, Problem, ResolutionKind, ResolutionOption } from "../types.js";
1+
import type { Package } from "../createPackage.ts";
2+
import type { CompilerHosts } from "./multiCompilerHost.ts";
3+
import type { Analysis, Problem, ResolutionKind, ResolutionOption } from "../types.ts";
44

55
export interface CheckDependenciesContext<EnumerateFiles extends boolean = false> extends CheckExecutionContext {
66
subpath: string;

0 commit comments

Comments
 (0)