Skip to content

Commit 1c96426

Browse files
authored
switch to NodeNext module resolution (#12179)
refs: #9005 ## Description This changes all tsconfig projects to use `moduleResolution: 'NodeNext'`, freeing us of ambients! There are still some globals via `exported.js` that we can burn down later but at least those are explicit. (The previous moduleResolution, 'bundler', was necessary because of our dependence on ambients. It's the mode that assumes everything will be turned into one giant bundle, so whatever hacks and heuristics the local TSC has to do to get the types to resolve is okay. But we actually do publish separate packages so need more strict type resolution behavior.) I used the hacky script in #12225 but am not proposing to merge that. We might need to run it again when getting off `exported.js` but we can either run it from the branch or do some more (separate) work to make it trunk-worthy. That script uses the TS language server to iterate over files and do the "auto-import" that VS Code does. By changing the moduleResolution from 'bundler' and running that, necessary types are auto-imported. When there's a duplicate name it doesn't always get the right one so some manual fixups were necessary. After doing this for every module in the repo, I was able to change the default so they all are 'NodeNext' now. ### Security Considerations none ### Scaling Considerations none ### Documentation Considerations Any downstream relying on the `types-ambient.js` exports will fail. The solution is just to import explicitly. I think that's a fine change to impose. ### Testing Considerations CI Nothing downstream will fail until it updates to a newer release and the fix for any ambients will be trivial. ### Upgrade Considerations does not affect chain
2 parents 2f5ba60 + 14231e9 commit 1c96426

File tree

211 files changed

+1010
-369
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

211 files changed

+1010
-369
lines changed

multichain-testing/scripts/ymax-tool.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ import {
4747
import { YieldProtocol } from '@agoric/portfolio-api/src/constants.js';
4848
import type { OfferStatus } from '@agoric/smart-wallet/src/offers.js';
4949
import type { NameHub } from '@agoric/vats';
50-
import type { StartedInstanceKit as ZStarted } from '@agoric/zoe/src/zoeService/utils';
50+
import type { StartedInstanceKit as ZStarted } from '@agoric/zoe/src/zoeService/utils.js';
5151
import { SigningStargateClient } from '@cosmjs/stargate';
5252
import { E } from '@endo/far';
5353
import { M } from '@endo/patterns';

multichain-testing/tools/batchQuery.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ async function* mapHistory(f, chunks) {
3838
}
3939

4040
/**
41-
* @param {ERef<import('./makeHttpClient').LCD>} lcd
41+
* @param {ERef<import('./makeHttpClient.js').LCD>} lcd
4242
*/
4343
export const makeVStorage = lcd => {
4444
// height=0 is the same as omitting height and implies the highest block

packages/ERTP/test/swingsetTests/ertpService/ertp-service-upgrade.test.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ import { test } from '@agoric/swingset-vat/tools/prepare-test-env-ava.js';
33
import { assert } from '@endo/errors';
44
import { buildVatController } from '@agoric/swingset-vat';
55

6+
/**
7+
* @import {SwingSetConfig} from '@agoric/swingset-vat';
8+
*/
9+
610
const bfile = name => new URL(name, import.meta.url).pathname;
711

812
test('ertp service upgrade', async t => {

packages/ERTP/tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
// This file can contain .js-specific Typescript compiler config.
22
{
33
"extends": "../../tsconfig.json",
4-
"compilerOptions": {},
4+
"compilerOptions": {
5+
},
56
"include": [
67
// omit exported.js because 1) it need not be included in the typecheck of
78
// this package because it's only consumed by other packages and 2)

packages/SwingSet/src/controller/controller.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,6 @@ export function computeSha512(bytes) {
8484
*/
8585
function makeConsole(prefixer) {
8686
if (typeof prefixer !== 'function') {
87-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
88-
// @ts-ignore TODO remove when anylogger has types
8987
const logger = anylogger(prefixer);
9088
return makeLimitedConsole(level => logger[level]);
9189
}
@@ -96,8 +94,6 @@ function makeConsole(prefixer) {
9694
const prefix = prefixer(source);
9795
let logger = prefixToLogger.get(prefix);
9896
if (!logger) {
99-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
100-
// @ts-ignore TODO remove when anylogger has types
10197
logger = anylogger(prefix);
10298
prefixToLogger.set(prefix, logger);
10399
}

packages/SwingSet/src/supervisors/subprocess-node/supervisor-subprocess-node.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,6 @@ function handleSetBundle(margs) {
130130
});
131131

132132
const makeLogMaker = tag => {
133-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
134-
// @ts-ignore TODO remove when anylogger has types
135133
const logger = anylogger(tag);
136134
const makeLog = level => {
137135
const log = logger[level];

packages/SwingSet/test/util.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,6 @@ export function makeRetireImports(...vrefs) {
140140
}
141141

142142
export const makeConsole = tag => {
143-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
144-
// @ts-ignore TODO remove when anylogger has types
145143
const log = anylogger(tag);
146144
const cons = /** @type {any} */ (
147145
Object.fromEntries(logLevels.map(level => [level, log[level]]))

packages/SwingSet/tsconfig.json

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
// This file can contain .js-specific Typescript compiler config.
22
{
33
"extends": "../../tsconfig.json",
4-
"compilerOptions": {
5-
// Default is "esnext" but we need "nodenext" to support ESM in Node.js
6-
"module": "nodenext",
7-
// Default is "bundler" which is too lax
8-
"moduleResolution": "nodenext",
9-
},
104
"include": [
115
"exported.js",
126
"demo/**/*.js",

packages/agoric-cli/src/anylogger-agoric.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ const selectedCode = anylogger.levels[selectedLevel];
2828
const globalCode = selectedCode === undefined ? -Infinity : selectedCode;
2929

3030
const oldExt = anylogger.ext;
31+
/** @type {typeof anylogger.ext} */
3132
anylogger.ext = (l, ...rest) => {
3233
l = oldExt(l, ...rest);
3334
l.enabledFor = lvl => globalCode >= anylogger.levels[lvl];

packages/agoric-cli/tools/resm-plugin/deploy.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { E } from '@endo/eventual-send';
33

44
const PONG_TIMEOUT = 10_000;
55

6+
// @ts-expect-error TS1287: A top-level 'export' modifier cannot be used on value declarations in a CommonJS module when 'verbatimModuleSyntax' is enabled.
67
export default async function deployPlugin(
78
homePromise,
89
{ installUnsafePlugin },

0 commit comments

Comments
 (0)