Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

more typedoc #1928

Merged
merged 10 commits into from
Jan 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"lerna": "^5.6.2",
"lerna-update-wizard": "^0.17.5",
"type-coverage": "^2.26.3",
"typedoc": "^0.25.4",
"typedoc": "^0.25.7",
"typescript": "~5.2.2"
},
"scripts": {
Expand Down
9 changes: 5 additions & 4 deletions packages/bundle-source/src/is-entrypoint.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// @ts-check
// Detect if this is run as a script.
import url from 'url';
import process from 'process';
import fs from 'fs';
import * as url from 'url';
import * as process from 'process';
import * as fs from 'fs';
Comment on lines +3 to +5
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the significance of this change? Why didn't it cause anything else to change?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These Node modules have no default exports. Under CommonJS the set of named exports could be treated as an object but under ESM you have to bundle the named exports into an object if you want to access them that way.


// Agoric still uses Endo dependencies under an emulation of ESM we call RESM
// because it is invoked with `node -r esm`.
Expand All @@ -13,4 +14,4 @@ const favor = (primary, secondary) =>
// FIXME: Should maybe be exported by '@endo/something'?
export const isEntrypoint = href =>
String(href) ===
url.pathToFileURL(fs.realpathSync(favor(process.argv[1]), '/')).href;
url.pathToFileURL(fs.realpathSync(favor(process.argv[1]))).href;
8 changes: 8 additions & 0 deletions packages/bundle-source/typedoc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": [
"../../typedoc.base.json"
],
"entryPoints": [
"src/index.js",
]
}
2 changes: 1 addition & 1 deletion packages/evasive-transform/src/generate.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import babelGenerator from '@agoric/babel-generator';
// OR, upgrading to Babel 8 probably addresses this defect.
// const { default: generator } = /** @type {any} */ (babelGenerator);
const generator = /** @type {typeof import('@babel/generator')['default']} */ (
// @ts-expect-error
// @ts-ignore -- errors but not in typedoc build
babelGenerator.default || babelGenerator
);

Expand Down
8 changes: 8 additions & 0 deletions packages/lockdown/typedoc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": [
"../../typedoc.base.json"
],
"entryPoints": [
"pre.js",
]
}
25 changes: 0 additions & 25 deletions packages/marshal/src/encodeToCapData.js
Original file line number Diff line number Diff line change
Expand Up @@ -346,11 +346,6 @@ export const makeDecodeFromCapData = (decodeOptions = {}) => {
return -Infinity;
}
case 'bigint': {
// Using @ts-ignore rather than @ts-expect-error below because
// with @ts-expect-error I get a red underline in vscode, but
// without it I get errors from `yarn lint`.
// @ts-ignore inadequate type inference
// See https://github.com/endojs/endo/pull/1259#discussion_r954561901
const { digits } = jsonEncoded;
typeof digits === 'string' ||
Fail`invalid digits typeof ${q(typeof digits)}`;
Expand All @@ -361,28 +356,13 @@ export const makeDecodeFromCapData = (decodeOptions = {}) => {
// on environment variable. Eventually remove, but after confident
// that there are no more supported senders.
//
// Using @ts-ignore rather than @ts-expect-error below because
// with @ts-expect-error I get a red underline in vscode, but
// without it I get errors from `yarn lint`.
// @ts-ignore inadequate type inference
// See https://github.com/endojs/endo/pull/1259#discussion_r954561901
return Symbol.asyncIterator;
}
case 'symbol': {
// Using @ts-ignore rather than @ts-expect-error below because
// with @ts-expect-error I get a red underline in vscode, but
// without it I get errors from `yarn lint`.
// @ts-ignore inadequate type inference
// See https://github.com/endojs/endo/pull/1259#discussion_r954561901
const { name } = jsonEncoded;
return passableSymbolForName(name);
}
case 'tagged': {
// Using @ts-ignore rather than @ts-expect-error below because
// with @ts-expect-error I get a red underline in vscode, but
// without it I get errors from `yarn lint`.
// @ts-ignore inadequate type inference
// See https://github.com/endojs/endo/pull/1259#discussion_r954561901
const { tag, payload } = jsonEncoded;
return makeTagged(tag, decodeFromCapData(payload));
}
Expand Down Expand Up @@ -411,11 +391,6 @@ export const makeDecodeFromCapData = (decodeOptions = {}) => {
throw Fail`internal: decodeErrorFromCapData option must return an error: ${decoded}`;
}
case 'hilbert': {
// Using @ts-ignore rather than @ts-expect-error below because
// with @ts-expect-error I get a red underline in vscode, but
// without it I get errors from `yarn lint`.
// @ts-ignore inadequate type inference
// See https://github.com/endojs/endo/pull/1259#discussion_r954561901
const { original, rest } = jsonEncoded;
hasOwnPropertyOf(jsonEncoded, 'original') ||
Fail`Invalid Hilbert Hotel encoding ${jsonEncoded}`;
Expand Down
16 changes: 8 additions & 8 deletions packages/marshal/src/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ export {};
/**
* @template Slot
* @callback ConvertValToSlot
* @param {import('@endo/pass-style').PassableCap} val
* @param {any} val a PassableCap
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That seems like a terrible regression, possibly due to types not being built!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not a regression. PassableCap in master is any.
Screenshot 2024-01-08 at 1 10 49 PM

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then the issue is with the PassableCap definition, not this param definition.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There was indeed an issue with the PassableCap definition. It was any. The type is still any so there's no regression here.

Once we fix those types, I expect to return to this.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix in #1933

* @returns {Slot}
*/

/**
* @template Slot
* @callback ConvertSlotToVal
* @param {Slot} slot
* @param {import('@endo/pass-style').InterfaceSpec} [iface]
* @returns {import('@endo/pass-style').PassableCap}
* @param {string} [iface]
* @returns {any} a PassableCap
*/

/**
Expand All @@ -34,7 +34,7 @@ export {};
* errorId?: string
* } |
* EncodingClass<'slot'> & { index: number,
* iface?: import('@endo/pass-style').InterfaceSpec
* iface?: string
* } |
* EncodingClass<'hilbert'> & { original: Encoding,
* rest?: Encoding
Expand Down Expand Up @@ -84,15 +84,15 @@ export {};
/**
* @template Slot
* @callback ToCapData
* @param {import('@endo/pass-style').Passable} val
* @param {any} val a Passable
* @returns {CapData<Slot>}
*/

/**
* @template Slot
* @callback FromCapData
* @param {CapData<Slot>} data
* @returns {import('@endo/pass-style').Passable}
* @returns {any} a Passable
*/

/**
Expand Down Expand Up @@ -172,8 +172,8 @@ export {};
* ordering would also compare magnitudes, and so agree with the rank ordering
* of all values other than `NaN`. An array sorted by rank would enable range
* queries by magnitude.
* @param {import('@endo/pass-style').Passable} left
* @param {import('@endo/pass-style').Passable} right
* @param {any} left a Passable
* @param {any} right a Passable
* @returns {RankComparison}
*/

Expand Down
15 changes: 8 additions & 7 deletions packages/marshal/test/test-marshal-capdata.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ import { makeMarshal } from '../src/marshal.js';

const { freeze, isFrozen, create, prototype: objectPrototype } = Object;

const harden = /** @type {import('ses').Harden & {isFake: boolean}} */ (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would the following also work? If so, I think it better documents the runtime reality it describes. Likewise for the other occurrences of course

Suggested change
const harden = /** @type {import('ses').Harden & {isFake: boolean}} */ (
const harden = /** @type {import('ses').Harden & {isFake?: boolean}} */ (

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it would. I'll see about adding tacking that onto another PR.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// eslint-disable-next-line no-undef
global.harden
);

// this only includes the tests that do not use liveSlots

/**
Expand Down Expand Up @@ -188,7 +193,6 @@ test('serialize static data', t => {
const m = makeTestMarshal();
const ser = val => m.serialize(val);

// @ts-ignore `isFake` purposely omitted from type
if (!harden.isFake) {
t.throws(() => ser([1, 2]), {
message: /Cannot pass non-frozen objects like/,
Expand Down Expand Up @@ -242,22 +246,20 @@ test('serialize errors', t => {

// Extra properties
const errExtra = Error('has extra properties');
// @ts-ignore Check dynamic consequences of type violation
// @ts-expect-error Check dynamic consequences of type violation
errExtra.foo = [];
freeze(errExtra);
t.assert(isFrozen(errExtra));
// @ts-ignore `isFake` purposely omitted from type
if (!harden.isFake) {
// @ts-ignore Check dynamic consequences of type violation
// @ts-expect-error Check dynamic consequences of type violation
t.falsy(isFrozen(errExtra.foo));
}
t.deepEqual(ser(errExtra), {
body: '{"@qclass":"error","errorId":"error:anon-marshal#10003","message":"has extra properties","name":"Error"}',
slots: [],
});
// @ts-ignore `isFake` purposely omitted from type
if (!harden.isFake) {
// @ts-ignore Check dynamic consequences of type violation
// @ts-expect-error Check dynamic consequences of type violation
t.falsy(isFrozen(errExtra.foo));
}

Expand Down Expand Up @@ -332,7 +334,6 @@ test('records', t => {

// empty objects

// @ts-ignore `isFake` purposely omitted from type
if (!harden.isFake) {
// rejected because it is not hardened
t.throws(
Expand Down
6 changes: 5 additions & 1 deletion packages/marshal/test/test-marshal-far-function.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ import { getInterfaceOf, passStyleOf, Far } from '@endo/pass-style';

const { freeze, setPrototypeOf } = Object;

const harden = /** @type {import('ses').Harden & {isFake: boolean}} */ (
// eslint-disable-next-line no-undef
global.harden
);

test('Far functions', t => {
t.notThrows(() => Far('arrow', a => a + 1), 'Far function');
const arrow = Far('arrow', a => a + 1);
Expand All @@ -21,7 +26,6 @@ test('Acceptable far functions', t => {
});

test('Unacceptable far functions', t => {
// @ts-ignore `isFake` purposely omitted from type
if (!harden.isFake) {
t.throws(
() =>
Expand Down
5 changes: 2 additions & 3 deletions packages/marshal/test/test-marshal-far-obj.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ const { create, getPrototypeOf, prototype: objectPrototype } = Object;

test('Remotable/getInterfaceOf', t => {
t.throws(
// @ts-ignore We're testing the dynamic consequences of this type violation
() => Remotable({ bar: 29 }),
{ message: /unimplemented/ },
'object ifaces are not implemented',
Expand Down Expand Up @@ -88,7 +87,7 @@ const testRecord = ({

const goodRemotableProto = testRecord();

// @ts-ignore We're testing bad things anyway
// @ts-expect-error We're testing bad things anyway
const badRemotableProto1 = testRecord({ styleSymbol: BAD_PASS_STYLE });

const badRemotableProto2 = testRecord({ styleString: 'string' });
Expand Down Expand Up @@ -215,7 +214,7 @@ test('transitional remotables', t => {
throw Error(`unknown option ${opt}`);
}
}
// @ts-ignore Don't yet understand typing, but want dynamic test anyway
// @ts-expect-error Don't yet understand typing, but want dynamic test anyway
const o = create(objectPrototype, props);
if (mark === 'far') {
return Far('iface', o);
Expand Down
15 changes: 8 additions & 7 deletions packages/marshal/test/test-marshal-smallcaps.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ import { roundTripPairs } from './test-marshal-capdata.js';

const { freeze, isFrozen, create, prototype: objectPrototype } = Object;

const harden = /** @type {import('ses').Harden & {isFake: boolean}} */ (
// eslint-disable-next-line no-undef
global.harden
);

// this only includes the tests that do not use liveSlots

/**
Expand All @@ -34,7 +39,6 @@ test('smallcaps serialize static data', t => {
const { serialize } = makeTestMarshal();
const ser = val => serialize(val);

// @ts-ignore `isFake` purposely omitted from type
if (!harden.isFake) {
t.throws(() => ser([1, 2]), {
message: /Cannot pass non-frozen objects like/,
Expand Down Expand Up @@ -102,22 +106,20 @@ test('smallcaps serialize errors', t => {

// Extra properties
const errExtra = Error('has extra properties');
// @ts-ignore Check dynamic consequences of type violation
// @ts-expect-error Check dynamic consequences of type violation
errExtra.foo = [];
freeze(errExtra);
t.assert(isFrozen(errExtra));
// @ts-ignore `isFake` purposely omitted from type
if (!harden.isFake) {
// @ts-ignore Check dynamic consequences of type violation
// @ts-expect-error Check dynamic consequences of type violation
t.falsy(isFrozen(errExtra.foo));
}
t.deepEqual(ser(errExtra), {
body: '#{"#error":"has extra properties","name":"Error"}',
slots: [],
});
// @ts-ignore `isFake` purposely omitted from type
if (!harden.isFake) {
// @ts-ignore Check dynamic consequences of type violation
// @ts-expect-error Check dynamic consequences of type violation
t.falsy(isFrozen(errExtra.foo));
}

Expand Down Expand Up @@ -186,7 +188,6 @@ test('smallcaps records', t => {

// empty objects

// @ts-ignore `isFake` purposely omitted from type
if (!harden.isFake) {
// rejected because it is not hardened
t.throws(
Expand Down
6 changes: 5 additions & 1 deletion packages/marshal/test/test-marshal-stringify.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ import { roundTripPairs } from './test-marshal-capdata.js';

const { isFrozen } = Object;

const harden = /** @type {import('ses').Harden & {isFake: boolean}} */ (
// eslint-disable-next-line no-undef
global.harden
);

test('stringify parse round trip pairs', t => {
for (const [plain, encoded] of roundTripPairs) {
const str = stringify(plain);
Expand All @@ -27,7 +32,6 @@ test('marshal parse', t => {
});

test('marshal stringify errors', t => {
// @ts-ignore `isFake` purposely omitted from type
if (!harden.isFake) {
t.throws(() => stringify([]), {
message: /Cannot pass non-frozen objects like .*. Use harden()/,
Expand Down
8 changes: 8 additions & 0 deletions packages/marshal/typedoc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": [
"../../typedoc.base.json"
],
"entryPoints": [
"index.js"
]
}
8 changes: 8 additions & 0 deletions packages/ses/typedoc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": [
"../../typedoc.base.json"
],
"entryPoints": [
"types.d.ts",
]
}
18 changes: 9 additions & 9 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -11053,10 +11053,10 @@ shell-quote@^1.6.1:
resolved "https://registry.yarnpkg.com/shell-quote/-/shell-quote-1.7.3.tgz#aa40edac170445b9a431e17bb62c0b881b9c4123"
integrity sha512-Vpfqwm4EnqGdlsBFNmHhxhElJYrdfcxPThu+ryKS5J8L/fhAwLazFZtq+S+TWZ9ANj2piSQLGj6NQg+lKPmxrw==

shiki@^0.14.1:
version "0.14.5"
resolved "https://registry.yarnpkg.com/shiki/-/shiki-0.14.5.tgz#375dd214e57eccb04f0daf35a32aa615861deb93"
integrity sha512-1gCAYOcmCFONmErGTrS1fjzJLA7MGZmKzrBNX7apqSwhyITJg2O102uFzXUeBxNnEkDA9vHIKLyeKq0V083vIw==
shiki@^0.14.7:
version "0.14.7"
resolved "https://registry.yarnpkg.com/shiki/-/shiki-0.14.7.tgz#c3c9e1853e9737845f1d2ef81b31bcfb07056d4e"
integrity sha512-dNPAPrxSc87ua2sKJ3H5dQ/6ZaY8RNnaAqK+t0eG7p0Soi2ydiqbGOTaZCqaYvA/uZYfS1LJnemt3Q+mSfcPCg==
dependencies:
ansi-sequence-parser "^1.1.0"
jsonc-parser "^3.2.0"
Expand Down Expand Up @@ -12204,15 +12204,15 @@ typedarray@^0.0.6:
resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777"
integrity sha512-/aCDEGatGvZ2BIk+HmLf4ifCJFwvKFNb9/JeZPMulfgFracn9QFcAf5GO8B/mweUjSoblS5In0cWhqpfs/5PQA==

typedoc@^0.25.4:
version "0.25.4"
resolved "https://registry.yarnpkg.com/typedoc/-/typedoc-0.25.4.tgz#5c2c0677881f504e41985f29d9aef0dbdb6f1e6f"
integrity sha512-Du9ImmpBCw54bX275yJrxPVnjdIyJO/84co0/L9mwe0R3G4FSR6rQ09AlXVRvZEGMUg09+z/usc8mgygQ1aidA==
typedoc@^0.25.7:
version "0.25.7"
resolved "https://registry.yarnpkg.com/typedoc/-/typedoc-0.25.7.tgz#11e3f527ca80ca3c029cb8e15f362e6d9f715e25"
integrity sha512-m6A6JjQRg39p2ZVRIN3NKXgrN8vzlHhOS+r9ymUYtcUP/TIQPvWSq7YgE5ZjASfv5Vd5BW5xrir6Gm2XNNcOow==
dependencies:
lunr "^2.3.9"
marked "^4.3.0"
minimatch "^9.0.3"
shiki "^0.14.1"
shiki "^0.14.7"

"typescript@^3 || ^4":
version "4.9.5"
Expand Down