Skip to content

Commit

Permalink
Revert "Use --experimental-transform-types"
Browse files Browse the repository at this point in the history
This reverts commit d3b1caf.
  • Loading branch information
andrewbranch committed Aug 26, 2024
1 parent d3b1caf commit c0e93a2
Show file tree
Hide file tree
Showing 37 changed files with 122 additions and 142 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
fetch-depth: 1
- uses: actions/setup-node@v3
with:
node-version: 22
node-version: 21
- uses: pnpm/action-setup@v2
with:
version: latest
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy-web.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
fetch-depth: 1
- uses: actions/setup-node@v3
with:
node-version: 22
node-version: 21
- uses: pnpm/action-setup@v2
with:
version: latest
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/version-or-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
fetch-depth: 1
- uses: actions/setup-node@v3
with:
node-version: 22
node-version: 21
- uses: pnpm/action-setup@v2
with:
version: latest
Expand Down
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,17 @@
"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"
},
"devDependencies": {
"@changesets/cli": "^2.27.1",
"prettier": "^3.0.3",
"typescript": "npm:@typescript-deploys/[email protected]"
"typescript": "5.6.1-rc"
},
"engines": {
"node": ">=22",
"node": ">=18",
"pnpm": ">=8"
}
}
3 changes: 1 addition & 2 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@
"tsc": "tsc -b",
"local:install": "npm install -g .",
"local:uninstall": "npm uninstall -g @arethetypeswrong/cli",
"test": "node --experimental-transform-types --conditions=@arethetypeswrong/source --test 'test/**/*.test.ts'",
"test-js": "node --experimental-transform-types --test 'test/**/*.test.ts'",
"test": "tsc -b test && node --test 'test/dist/**/*.test.js'",
"prepack": "pnpm tsc"
},
"type": "module",
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/getExitCode.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { CheckResult } from "@arethetypeswrong/core";
import { problemFlags } from "./problemUtils.ts";
import type { RenderOptions } from "./render/index.ts";
import { problemFlags } from "./problemUtils.js";
import type { RenderOptions } from "./render/index.js";

export function getExitCode(analysis: CheckResult, opts?: RenderOptions): number {
if (!analysis.types) {
Expand Down
12 changes: 6 additions & 6 deletions packages/cli/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.ts";
import { readConfig } from "./readConfig.ts";
import * as render from "./render/index.ts";
import { problemFlags } from "./problemUtils.js";
import { readConfig } from "./readConfig.js";
import * as render from "./render/index.js";
import { major, minor } from "semver";
import { getExitCode } from "./getExitCode.ts";
import { getExitCode } from "./getExitCode.js";

const packageJson = createRequire(import.meta.url)("../package.json");
const version = packageJson.version;
Expand Down Expand Up @@ -74,8 +74,8 @@ particularly ESM-related module resolution issues.`,
.option("--exclude-entrypoints <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 <rules...>", "Specify rules to ignore").choices(Object.values(problemFlags)).default([]),
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/readConfig.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Command } from "commander";
import { readFile } from "fs/promises";
import { problemFlags } from "./problemUtils.ts";
import { problemFlags } from "./problemUtils.js";

export async function readConfig(program: Command, alternate = ".attw.json") {
try {
Expand Down
6 changes: 3 additions & 3 deletions packages/cli/src/render/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { problemFlags } from "../problemUtils.ts";
import type { problemFlags } from "../problemUtils.js";

export type Format = "auto" | "table" | "table-flipped" | "ascii" | "json";
export interface RenderOptions {
Expand All @@ -9,5 +9,5 @@ export interface RenderOptions {
emoji?: boolean;
}

export * from "./typed.ts";
export * from "./untyped.ts";
export * from "./typed.js";
export * from "./untyped.js";
6 changes: 3 additions & 3 deletions packages/cli/src/render/typed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.ts";
import { asciiTable } from "./asciiTable.ts";
import type { RenderOptions } from "./index.ts";
import { moduleKinds, problemFlags, resolutionKinds } from "../problemUtils.js";
import { asciiTable } from "./asciiTable.js";
import type { RenderOptions } from "./index.js";

export async function typed(
analysis: core.Analysis,
Expand Down
41 changes: 20 additions & 21 deletions packages/cli/test/snapshots.test.ts
Original file line number Diff line number Diff line change
@@ -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 = new URL("../src/index.ts", import.meta.url).pathname;
const attw = `node ${new URL("../../dist/index.js", import.meta.url).pathname}`;
const updateSnapshots = process.env.UPDATE_SNAPSHOTS || process.env.U;
const testFilter = (process.env.TEST_FILTER || process.env.T)?.toLowerCase();

Expand Down Expand Up @@ -34,11 +34,11 @@ const tests = [

[
"[email protected]",
`--definitely-typed ${new URL("../../core/test/fixtures/@[email protected]", import.meta.url).pathname}`,
`--definitely-typed ${new URL("../../../core/test/fixtures/@[email protected]", import.meta.url).pathname}`,
],
[
"[email protected]",
`--definitely-typed ${new URL("../../core/test/fixtures/@[email protected]", import.meta.url).pathname}`,
`--definitely-typed ${new URL("../../../core/test/fixtures/@[email protected]", import.meta.url).pathname}`,
],

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

test(fixture, async () => {
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(" ")],
{
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}`, {
encoding: "utf8",
stdio: "pipe",
env: { ...process.env, FORCE_COLOR: "0", NODE_OPTIONS: "--no-warnings" },
},
);

const snapshotURL = new URL(`snapshots/${fixture}.md`, import.meta.url);
env: { ...process.env, FORCE_COLOR: "0" },
});
} catch (error) {
stdout = (error as SpawnSyncReturns<string>).stdout;
stderr = (error as SpawnSyncReturns<string>).stderr;
exitCode = (error as SpawnSyncReturns<string>).status ?? 1;
}
const snapshotURL = new URL(`../snapshots/${fixture}.md`, import.meta.url);
// prettier-ignore
const expectedSnapshot = [
`# ${fixture}`,
Expand All @@ -95,7 +94,7 @@ describe("snapshots", async () => {
"",
"```",
"",
`Exit code: ${status}`,
`Exit code: ${exitCode}`,
].join("\n");

if (
Expand Down
8 changes: 7 additions & 1 deletion packages/cli/test/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
{
"extends": "../../../tsconfig.test.json",
"extends": "../../../tsconfig.base.json",
"compilerOptions": {
"lib": ["es2019"],
"module": "nodenext",
"outDir": "dist",
"types": ["node"]
},
"references": [
{
"path": ".."
Expand Down
1 change: 0 additions & 1 deletion packages/cli/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"module": "nodenext",
"rewriteRelativeImportExtensions": true,
"rootDir": "src",
"types": ["node", "ts-expose-internals"],
"outDir": "./dist",
Expand Down
16 changes: 6 additions & 10 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,33 +19,29 @@
},
"scripts": {
"tsc": "tsc",
"test": "node --experimental-transform-types --conditions=@arethetypeswrong/source --test 'test/**/*.test.ts'",
"test-js": "node --experimental-transform-types --test 'test/**/*.test.ts'",
"test": "tsc -b test && node --test 'test/dist/**/*.test.js'",
"snapshot": "node scripts/createSnapshotFixture.js",
"prepack": "pnpm tsc"
},
"type": "module",
"imports": {
"#internal/*": {
"@arethetypeswrong/source": "./src/internal/*.ts",
"default": "./dist/internal/*.js"
}
"#internal/*": "./dist/internal/*"
},
"exports": {
".": {
"@arethetypeswrong/source": "./src/index.ts",
"development": "./src/index.ts",
"default": "./dist/index.js"
},
"./types": {
"@arethetypeswrong/source": "./src/types.ts",
"development": "./src/types.ts",
"default": "./dist/types.js"
},
"./utils": {
"@arethetypeswrong/source": "./src/utils.ts",
"development": "./src/utils.ts",
"default": "./dist/utils.js"
},
"./problems": {
"@arethetypeswrong/source": "./src/problems.ts",
"development": "./src/problems.ts",
"default": "./dist/problems.js"
},
"./versions": {
Expand Down
14 changes: 7 additions & 7 deletions packages/core/src/checkPackage.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
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 { 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 {
AnalysisTypes,
CheckResult,
EntrypointResolutionAnalysis,
Problem,
ProgramInfo,
ResolutionOption,
} from "./types.ts";
import { getResolutionOption, visitResolutions } from "./utils.ts";
import { getEntrypointInfo, getModuleKinds, getBuildTools } from "./internal/getEntrypointInfo.ts";
} from "./types.js";
import { getResolutionOption, visitResolutions } from "./utils.js";
import { getEntrypointInfo, getModuleKinds, getBuildTools } from "./internal/getEntrypointInfo.js";

export interface CheckPackageOptions {
/**
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/createPackage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.ts";
import { parsePackageSpec, type ParsedPackageSpec } from "./utils.js";

export class Package {
#files: Record<string, string | Uint8Array> = {};
Expand Down
6 changes: 3 additions & 3 deletions packages/core/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export * from "./checkPackage.ts";
export * from "./createPackage.ts";
export type * from "./types.ts";
export * from "./checkPackage.js";
export * from "./createPackage.js";
export type * from "./types.js";
2 changes: 1 addition & 1 deletion packages/core/src/internal/checks/cjsOnlyExportsDefault.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import ts from "typescript";
import { defineCheck } from "../defineCheck.ts";
import { defineCheck } from "../defineCheck.js";

export default defineCheck({
name: "CJSOnlyExportsDefault",
Expand Down
6 changes: 3 additions & 3 deletions packages/core/src/internal/checks/entrypointResolutions.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import ts from "typescript";
import type { Problem } from "../../types.ts";
import { resolvedThroughFallback } from "../../utils.ts";
import { defineCheck } from "../defineCheck.ts";
import type { Problem } from "../../types.js";
import { resolvedThroughFallback } from "../../utils.js";
import { defineCheck } from "../defineCheck.js";

export default defineCheck({
name: "EntrypointResolutions",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import ts from "typescript";
import { defineCheck } from "../defineCheck.ts";
import { getProbableExports, type Export } from "../getProbableExports.ts";
import { getResolutionOption } from "../../utils.ts";
import { defineCheck } from "../defineCheck.js";
import { getProbableExports, type Export } from "../getProbableExports.js";
import { getResolutionOption } from "../../utils.js";

const bindOptions: ts.CompilerOptions = {
target: ts.ScriptTarget.Latest,
Expand Down
12 changes: 6 additions & 6 deletions packages/core/src/internal/checks/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
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";
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";

export default [
entrypointResolutions,
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/internal/checks/internalResolutionError.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import ts from "typescript";
import { defineCheck } from "../defineCheck.ts";
import type { InternalResolutionErrorProblem } from "../../types.ts";
import { defineCheck } from "../defineCheck.js";
import type { InternalResolutionErrorProblem } from "../../types.js";

export default defineCheck({
name: "InternalResolutionError",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import ts from "typescript";
import { defineCheck } from "../defineCheck.ts";
import { defineCheck } from "../defineCheck.js";

export default defineCheck({
name: "ModuleKindDisagreement",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import ts from "typescript";
import { defineCheck } from "../defineCheck.ts";
import { defineCheck } from "../defineCheck.js";

export default defineCheck({
name: "UnexpectedModuleSyntax",
Expand Down
6 changes: 3 additions & 3 deletions packages/core/src/internal/defineCheck.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Package } from "../createPackage.ts";
import type { CompilerHosts } from "./multiCompilerHost.ts";
import type { Analysis, Problem, ResolutionKind, ResolutionOption } from "../types.ts";
import type { Package } from "../createPackage.js";
import type { CompilerHosts } from "./multiCompilerHost.js";
import type { Analysis, Problem, ResolutionKind, ResolutionOption } from "../types.js";

export interface CheckDependenciesContext<EnumerateFiles extends boolean = false> extends CheckExecutionContext {
subpath: string;
Expand Down
Loading

0 comments on commit c0e93a2

Please sign in to comment.