Skip to content

Commit 0aed25f

Browse files
committed
Small fixes
1 parent 58dbbc9 commit 0aed25f

File tree

10 files changed

+44
-72
lines changed

10 files changed

+44
-72
lines changed

package-lock.json

Lines changed: 9 additions & 47 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"@types/node": "^18.11.18",
2222
"esbuild": "^0.18.12",
2323
"prettier": "^3.0.3",
24-
"typescript": "^5.3.0-dev.20231007"
24+
"typescript": "^5.2.2"
2525
},
2626
"volta": {
2727
"node": "19.8.1"

packages/cli/src/render/typed.ts

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,12 @@ export async function typed(analysis: core.Analysis, opts: Opts) {
6969
return chalk.bold[color](entrypointNames[i]);
7070
});
7171

72-
const getCellContents = memo((entrypoint: string, resolutionKind: core.ResolutionKind) => {
73-
const problemsForCell = groupProblemsByKind(filterProblems(problems, analysis, { entrypoint, resolutionKind }));
74-
const resolution = analysis.entrypoints[entrypoint].resolutions[resolutionKind].resolution;
72+
const getCellContents = memo((subpath: string, resolutionKind: core.ResolutionKind) => {
73+
const problemsForCell = groupProblemsByKind(
74+
filterProblems(problems, analysis, { entrypoint: subpath, resolutionKind }),
75+
);
76+
const entrypoint = analysis.entrypoints[subpath].resolutions[resolutionKind];
77+
const resolution = entrypoint.resolution;
7578
const kinds = Object.keys(problemsForCell) as core.ProblemKind[];
7679
if (kinds.length) {
7780
return kinds
@@ -80,12 +83,13 @@ export async function typed(analysis: core.Analysis, opts: Opts) {
8083
}
8184

8285
const jsonResult = !opts.emoji ? "OK (JSON)" : "🟢 (JSON)";
83-
const moduleResult =
84-
(!opts.emoji ? "OK " : "🟢 ") +
85-
moduleKinds[
86-
analysis.programInfo[getResolutionOption(resolutionKind)].moduleKinds?.[resolution?.fileName ?? ""]
87-
?.detectedKind || ""
88-
];
86+
const moduleResult = entrypoint.isWildcard
87+
? "(wildcard)"
88+
: (!opts.emoji ? "OK " : "🟢 ") +
89+
moduleKinds[
90+
analysis.programInfo[getResolutionOption(resolutionKind)].moduleKinds?.[resolution?.fileName ?? ""]
91+
?.detectedKind || ""
92+
];
8993
return resolution?.isJson ? jsonResult : moduleResult;
9094
});
9195

packages/core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
"devDependencies": {
5858
"@types/node": "^18.15.11",
5959
"@types/semver": "^7.5.0",
60-
"@types/ts-expose-internals": "npm:ts-expose-internals@5.1.3",
60+
"@types/ts-expose-internals": "npm:ts-expose-internals@5.2.2",
6161
"@types/validate-npm-package-name": "^4.0.0"
6262
},
6363
"volta": {

packages/core/src/checkPackage.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -241,11 +241,8 @@ function getEntrypointResolution(
241241
const moduleSpecifier = packageName + entrypoint.substring(1); // remove leading . before slash
242242
const importingFileName = resolutionKind === "node16-esm" ? "/index.mts" : "/index.ts";
243243
const resolutionMode = resolutionKind === "node16-esm" ? ts.ModuleKind.ESNext : ts.ModuleKind.CommonJS;
244-
245244
const resolution = tryResolve();
246-
const implementationResolution =
247-
!resolution || ts.isDeclarationFileName(resolution.fileName) ? tryResolve(/*noDtsResolution*/ true) : undefined;
248-
245+
const implementationResolution = tryResolve(/*noDtsResolution*/ true);
249246
const files = resolution
250247
? host
251248
.createProgram([resolution.fileName])

packages/core/src/internal/checks/entrypointResolutions.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ export default defineCheck({
99
execute: ([subpath, resolutionKind], context) => {
1010
const problems: Problem[] = [];
1111
const entrypoint = context.entrypoints[subpath].resolutions[resolutionKind];
12+
if (entrypoint.isWildcard) {
13+
return;
14+
}
15+
1216
if (!entrypoint.resolution) {
1317
problems.push({
1418
kind: "NoResolution",
@@ -24,9 +28,14 @@ export default defineCheck({
2428
}
2529

2630
if (
27-
entrypoint.resolution &&
2831
resolutionKind === "node16-cjs" &&
29-
context.programInfo["node16"].moduleKinds![entrypoint.resolution.fileName].detectedKind === ts.ModuleKind.ESNext
32+
((!entrypoint.implementationResolution &&
33+
entrypoint.resolution &&
34+
context.programInfo["node16"].moduleKinds![entrypoint.resolution.fileName]?.detectedKind ===
35+
ts.ModuleKind.ESNext) ||
36+
(entrypoint.implementationResolution &&
37+
context.programInfo["node16"].moduleKinds![entrypoint.implementationResolution.fileName]?.detectedKind ===
38+
ts.ModuleKind.ESNext))
3039
) {
3140
problems.push({
3241
kind: "CJSResolvesToESM",

packages/core/src/internal/checks/exportDefaultDisagreement.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export default defineCheck({
1616
return [typesFileName, implementationFileName];
1717
},
1818
execute: ([typesFileName, implementationFileName], context) => {
19-
if (!typesFileName || !implementationFileName) {
19+
if (!typesFileName || !implementationFileName || !ts.hasTSFileExtension(typesFileName)) {
2020
return;
2121
}
2222
const host = context.hosts.findHostForFiles([typesFileName])!;

packages/core/src/internal/checks/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ import moduleKindDisagreement from "./moduleKindDisagreement.js";
66
import unexpectedModuleSyntax from "./unexpectedModuleSyntax.js";
77

88
export default [
9-
cjsOnlyExportsDefault,
109
entrypointResolutions,
11-
exportDefaultDisagreement,
12-
internalResolutionError,
1310
moduleKindDisagreement,
11+
exportDefaultDisagreement,
12+
cjsOnlyExportsDefault,
1413
unexpectedModuleSyntax,
14+
internalResolutionError,
1515
];

packages/core/src/internal/defineCheck.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,16 @@ export type Serializable =
3636
| undefined
3737
| boolean
3838
| { [key: string]: Serializable }
39-
| Serializable[];
39+
| readonly Serializable[];
4040

4141
export interface AnyCheck {
4242
name: string;
4343
enumerateFiles?: boolean;
44-
dependencies: (context: CheckDependenciesContext<boolean>) => EnsureSerializable<any[]>;
44+
dependencies: (context: CheckDependenciesContext<boolean>) => EnsureSerializable<readonly any[]>;
4545
execute: (dependencies: any, context: CheckExecutionContext) => Problem[] | Problem | undefined;
4646
}
4747

48-
export function defineCheck<const Dependencies extends any[], EnumerateFiles extends boolean>(options: {
48+
export function defineCheck<const Dependencies extends readonly any[], EnumerateFiles extends boolean>(options: {
4949
name: string;
5050
enumerateFiles?: EnumerateFiles;
5151
dependencies: (context: CheckDependenciesContext<EnumerateFiles>) => EnsureSerializable<Dependencies>;

packages/web/src/views/ChecksTable.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export function ChecksTable(props: { analysis?: CheckResult }) {
6161
)
6262
.join("<br />")
6363
: resolutionInfo.isWildcard
64-
? "(wildcard)"
64+
? "(wildcard)"
6565
: resolutionInfo.resolution?.isJson
6666
? "✅ (JSON)"
6767
: "✅ " +

0 commit comments

Comments
 (0)