Skip to content

Commit

Permalink
Merge pull request #6500 from Agoric/1254-export-types
Browse files Browse the repository at this point in the history
export types
  • Loading branch information
mergify[bot] authored Nov 1, 2022
2 parents 0534694 + 135bf05 commit aad309a
Show file tree
Hide file tree
Showing 195 changed files with 467 additions and 390 deletions.
12 changes: 12 additions & 0 deletions packages/ERTP/jsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"extends": "./jsconfig.json",
"compilerOptions": {
"noEmit": false,
"declaration": true,
"emitDeclarationOnly": true,
"declarationMap": true
},
"exclude": [
"test/"
]
}
19 changes: 10 additions & 9 deletions packages/ERTP/jsconfig.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
// This file can contain .js-specific Typescript compiler config.
{
"compilerOptions": {
"target": "esnext",
"module": "esnext",

"checkJs": true,
"noEmit": true,
/*
// The following flags are for creating .d.ts files:
"noEmit": false,
"declaration": true,
"emitDeclarationOnly": true,
*/
"downlevelIteration": true,
"strictNullChecks": true,
"moduleResolution": "node",
"types": [
"node"
]
},
"include": ["src/**/*.js", "test/**/*.js", "exported.js", "globals.d.ts"],
"include": [
"*.js",
"*.ts",
"src/**/*.js",
"src/**/*.ts"
]
}
3 changes: 3 additions & 0 deletions packages/ERTP/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
},
"scripts": {
"build": "exit 0",
"clean": "tsc --build jsconfig.build.json --clean",
"prepack": "tsc --build jsconfig.build.json",
"postpack": "yarn clean",
"test": "ava",
"test:c8": "c8 $C8_OPTIONS ava",
"test:xs": "yarn test:xs-unit && yarn test:xs-worker",
Expand Down
2 changes: 0 additions & 2 deletions packages/ERTP/src/amountMath.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// @ts-check

import { passStyleOf, assertRemotable, assertRecord } from '@endo/marshal';

import './types.js';
Expand Down
2 changes: 0 additions & 2 deletions packages/ERTP/src/displayInfo.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// @ts-check

import { assert, details as X } from '@agoric/assert';
import { fit } from '@agoric/store';

Expand Down
2 changes: 0 additions & 2 deletions packages/ERTP/src/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// @ts-check

export * from './amountMath.js';
export * from './issuerKit.js';
export * from './typeGuards.js';
1 change: 0 additions & 1 deletion packages/ERTP/src/issuerKit.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// @ts-check
// @jessie-check

import { assert } from '@agoric/assert';
Expand Down
2 changes: 0 additions & 2 deletions packages/ERTP/src/mathHelpers/copyBagMathHelpers.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// @ts-check

import {
keyEQ,
makeCopyBag,
Expand Down
2 changes: 0 additions & 2 deletions packages/ERTP/src/mathHelpers/copySetMathHelpers.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// @ts-check

import {
keyEQ,
makeCopySet,
Expand Down
2 changes: 0 additions & 2 deletions packages/ERTP/src/mathHelpers/natMathHelpers.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// @ts-check

import { Nat, isNat } from '@agoric/nat';

import '../types.js';
Expand Down
2 changes: 0 additions & 2 deletions packages/ERTP/src/mathHelpers/setMathHelpers.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// @ts-check

import { passStyleOf } from '@endo/marshal';
import {
assertKey,
Expand Down
2 changes: 0 additions & 2 deletions packages/ERTP/src/payment.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// @ts-check

import { initEmpty } from '@agoric/store';
import { vivifyFarClass } from '@agoric/vat-data';

Expand Down
2 changes: 0 additions & 2 deletions packages/ERTP/src/paymentLedger.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
/* eslint-disable no-use-before-define */
// @ts-check

import { isPromise } from '@endo/promise-kit';
import { assertCopyArray } from '@endo/marshal';
import { fit, M } from '@agoric/store';
Expand Down
2 changes: 0 additions & 2 deletions packages/ERTP/src/transientNotifier.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// @ts-check

import { makeScalarBigWeakMapStore } from '@agoric/vat-data';
import { provideLazy } from '@agoric/store';
import { makeNotifierKit } from '@agoric/notifier';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// @ts-check

import { Far } from '@endo/marshal';
import {
makeScalarBigMapStore,
Expand Down
2 changes: 0 additions & 2 deletions packages/ERTP/test/swingsetTests/splitPayments/bootstrap.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// @ts-check

import { E } from '@endo/eventual-send';
import { assert, details as X } from '@agoric/assert';
import { Far } from '@endo/marshal';
Expand Down
2 changes: 0 additions & 2 deletions packages/ERTP/test/swingsetTests/splitPayments/vat-alice.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// @ts-check

import { E } from '@endo/eventual-send';
import { Far } from '@endo/marshal';
import { AmountMath } from '../../../src/index.js';
Expand Down
2 changes: 1 addition & 1 deletion packages/SwingSet/docs/liveslots.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Most SwingSet vats use liveslots (with the notable exception of the comms vat).

```js

export buildRootObject(_vatPowers) {
export buildRootObject() {
const obj0 = Far('root', {
foo(arg1, arg2) {
// implement foo
Expand Down
2 changes: 1 addition & 1 deletion packages/SwingSet/src/kernel/state/kernelKeeper.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ const FIRST_METER_ID = 1n;

/**
* @param {HostStore} hostStorage
* @param {KernelSlog} kernelSlog
* @param {KernelSlog | null} kernelSlog
* @param {import('../../lib-nodejs/hasher.js').CreateSHA256} createSHA256
*/
export default function makeKernelKeeper(
Expand Down
2 changes: 1 addition & 1 deletion packages/SwingSet/src/types-external.js
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ export {};
*
* @typedef { string } BundleID
* @typedef {*} BundleCap
* @typedef { { moduleFormat: 'endoZipBase64', endoZipBase64: string, endoZipBase64Sha512 } } EndoZipBase64Bundle
* @typedef { { moduleFormat: 'endoZipBase64', endoZipBase64: string, endoZipBase64Sha512: string } } EndoZipBase64Bundle
*
* @typedef { unknown } Meter
*
Expand Down
15 changes: 7 additions & 8 deletions packages/SwingSet/src/vats/plugin-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@ const DEFAULT_WALKER = Far('walker', { walk: pluginRootP => pluginRootP });

/**
* @template T
* @typedef {T} Device
* @typedef {'Device' & { __deviceType__: T }} Device
*/

/** @typedef {<T>(target: Device<T>) => T} DProxy (approximately) */

/**
* @callback LoadPlugin
* @param {string} specifier
Expand All @@ -49,18 +51,15 @@ const DEFAULT_WALKER = Far('walker', { walk: pluginRootP => pluginRootP });
*/

/**
* @typedef {object} PluginDevice
* @property {(mod: string) => number} connect
* @property {(receiver: Receiver) => void} registerReceiver
* @property {(index: number, obj: Record<string, any>) => void} send
* @property {() => string} getPluginDir
* @typedef { Device<ReturnType<typeof
* import('@agoric/swingset-vat/src/devices/plugin/device-plugin.js').buildRootDeviceNode>> } PluginDevice
*/

/**
* Create a handler that manages a promise interface to external modules.
*
* @param {Device<PluginDevice>} pluginDevice The bridge to manage
* @param {{ [prop: string]: any, D: <T>(target: Device<T>) => T}} param1
* @param {PluginDevice} pluginDevice The bridge to manage
* @param {{ [prop: string]: any, D: DProxy }} param1
* @returns {PluginManager} admin facet for this handler
*/
export function makePluginManager(pluginDevice, { D, ...vatPowers }) {
Expand Down
2 changes: 1 addition & 1 deletion packages/SwingSet/test/basedir-circular/bootstrap.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { E } from '@endo/eventual-send';
import { Far } from '@endo/marshal';

export function buildRootObject(_vatPowers) {
export function buildRootObject() {
return Far('root', {
bootstrap(vats) {
const pa = E(vats.bob).genPromise1();
Expand Down
2 changes: 1 addition & 1 deletion packages/SwingSet/test/basedir-circular/vat-bob.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ function makePR() {
return [p, r];
}

export function buildRootObject(_vatPowers) {
export function buildRootObject() {
let p1;
let r1;
let p2;
Expand Down
2 changes: 1 addition & 1 deletion packages/SwingSet/test/definition/vat-liveslots.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Far, getInterfaceOf } from '@endo/marshal';

export function buildRootObject(_vatPowers) {
export function buildRootObject() {
let counter = 0;
return Far('root', {
increment() {
Expand Down
2 changes: 1 addition & 1 deletion packages/SwingSet/test/definition/vat-setup.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Far, getInterfaceOf } from '@endo/marshal';

export function buildRootObject(_vatPowers) {
export function buildRootObject() {
let counter = 0;
return Far('root', {
increment() {
Expand Down
2 changes: 1 addition & 1 deletion packages/SwingSet/test/gc-device-transfer/vat-left-gc.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Far } from '@endo/marshal';

export function buildRootObject(_vatPowers) {
export function buildRootObject() {
return Far('left', {
async forget(_amy) {
// just drop the argument
Expand Down
2 changes: 1 addition & 1 deletion packages/SwingSet/test/test-liveslots.js
Original file line number Diff line number Diff line change
Expand Up @@ -1509,7 +1509,7 @@ test('buildVatNamespace not called until after startVat', async t => {
const gcTools = makeMockGC();
let buildCalled = false;

function buildRootObject(_vatPowers) {
function buildRootObject() {
buildCalled = true;
return Far('root', {});
}
Expand Down
2 changes: 1 addition & 1 deletion packages/SwingSet/test/vat-activityhash-comms.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { E } from '@endo/eventual-send';
import { Far } from '@endo/marshal';

export function buildRootObject(_vatPowers) {
export function buildRootObject() {
let comms;

async function addNewRemote(name) {
Expand Down
2 changes: 1 addition & 1 deletion packages/SwingSet/test/vat-admin/broken-module-vat.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// eslint-disable-next-line no-undef
missing({});

export function buildRootObject(_vatPowers) {
export function buildRootObject() {
return {};
}
2 changes: 1 addition & 1 deletion packages/SwingSet/test/vat-admin/broken-root-vat.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export function buildRootObject(_vatPowers) {
export function buildRootObject() {
// eslint-disable-next-line no-undef
return missing({});
}
2 changes: 1 addition & 1 deletion packages/SwingSet/test/vat-xsnap-hang.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Far } from '@endo/marshal';

export function buildRootObject(_vatPowers) {
export function buildRootObject() {
return Far('root', {
hang() {
// eslint-disable-next-line no-empty
Expand Down
2 changes: 1 addition & 1 deletion packages/SwingSet/test/virtualObjects/vat-vom-gc-bob.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { defineKind } from '@agoric/vat-data';

const things = [];

export function buildRootObject(_vatPowers) {
export function buildRootObject() {
const makeThing = defineKind('thing', label => ({ label }), {
getLabel: ({ state }) => state.label,
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { E } from '@endo/eventual-send';
import { Far } from '@endo/marshal';

export function buildRootObject(_vatPowers) {
export function buildRootObject() {
// eslint thinks 'other' is unused, but eslint is wrong.
// eslint-disable-next-line no-unused-vars
let other;
Expand Down
13 changes: 0 additions & 13 deletions packages/SwingSet/tools/internal-types.js
Original file line number Diff line number Diff line change
@@ -1,13 +0,0 @@
/**
* @typedef {object} ManualTimerAdmin
* @property { (when: Timestamp) => void } advanceTo
*/

/**
* @typedef {ManualTimerAdmin & TimerService} ManualTimer
*/

/**
* @typedef {object} ManualTimerOptions
* @property {Timestamp} [startTime=0n]
*/
4 changes: 3 additions & 1 deletion packages/SwingSet/tools/manual-timer.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-check
import { Far } from '@endo/marshal';
import { makeScalarMapStore } from '@agoric/store';
import { bindAllMethods } from '@agoric/internal';
Expand All @@ -6,6 +7,7 @@ import { buildRootObject } from '../src/vats/timer/vat-timer.js';
// adapted from 'setup()' in test-vat-timer.js

const setup = () => {
/** @type {{ now: bigint, currentWakeup: any, currentHandler: any }} */
const state = {
now: 0n, // current time, updated during test
currentWakeup: undefined,
Expand Down Expand Up @@ -52,7 +54,7 @@ const setup = () => {
* A fake TimerService, for unit tests that do not use a real
* kernel. You can make time pass by calling `advanceTo(when)`.
*
* @param {ManualTimerOptions} [options]
* @param {{ startTime?: Timestamp }} [options]
* @returns {TimerService & { advanceTo: (when: Timestamp) => void; }}
*/
export const buildManualTimer = (options = {}) => {
Expand Down
2 changes: 2 additions & 0 deletions packages/agoric-cli/src/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ import chalk from 'chalk';
import { makePspawn } from './helpers.js';

// Ambient types. Needed only for dev but this does a runtime import.
// https://github.com/Agoric/agoric-sdk/issues/6512
import '@endo/captp/src/types.js';
import '@agoric/swingset-vat/exported.js';
import '@agoric/swingset-vat/src/vats/network/types.js';

// Use either an absolute template URL, or find it relative to DAPP_URL_BASE.
const gitURL = (relativeOrAbsoluteURL, base) => {
Expand Down
12 changes: 12 additions & 0 deletions packages/governance/jsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"extends": "./jsconfig.json",
"compilerOptions": {
"noEmit": false,
"declaration": true,
"emitDeclarationOnly": true,
"declarationMap": true
},
"exclude": [
"test/"
]
}
8 changes: 0 additions & 8 deletions packages/governance/jsconfig.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,8 @@
// This file can contain .js-specific Typescript compiler config.
{
"compilerOptions": {
"target": "esnext",
"module": "esnext",

"noEmit": true,
/*
// The following flags are for creating .d.ts files:
"noEmit": false,
"declaration": true,
"emitDeclarationOnly": true,
*/
"downlevelIteration": true,
"strictNullChecks": true,
"moduleResolution": "node",
Expand Down
3 changes: 3 additions & 0 deletions packages/governance/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
"scripts": {
"build": "yarn build:bundles",
"build:bundles": "node ./scripts/build-bundles.js",
"clean": "tsc --build jsconfig.build.json --clean",
"prepack": "tsc --build jsconfig.build.json",
"postpack": "yarn clean",
"test": "ava",
"test:c8": "c8 $C8_OPTIONS ava --config=ava-nesm.config.js",
"test:xs": "exit 0",
Expand Down
Loading

0 comments on commit aad309a

Please sign in to comment.