style: Lint TypeScript
MODIFY
packages/daemon/index.d.ts
packages/daemon/index.d.ts
type Locator = {
- endoPath: string,
- logPath: string,
- sockPath: string,
+ endoPath: string;
+ logPath: string;
+ sockPath: string;
};
export async function start(locator?: Locator);
export async function stop(locator?: Locator);

MODIFY
packages/eventual-send/src/index.d.ts
packages/eventual-send/src/index.d.ts
-/* eslint-disable no-shadow,no-unused-vars,no-use-before-define,no-var,vars-on-top */
+/* eslint-disable no-shadow,no-use-before-define,no-var,vars-on-top */
// Type definitions for eventual-send
// TODO: Add jsdocs.

MODIFY
packages/netstring/index.d.ts
packages/netstring/index.d.ts
export { netstringReader, netstringWriter } from './index.js';
export { makeNetstringReader, makeNetstringWriter } from './index.js';
-export type { Stream } from './stream.js';
+export { Stream } from './stream.js';

MODIFY
packages/ses-types-test/validation.ts
packages/ses-types-test/validation.ts
-/* eslint-disable no-unused-vars, no-underscore-dangle */
+/* eslint-disable no-underscore-dangle */
/// <reference types="ses"/>
// eslint-disable-next-line prettier/prettier

MODIFY
packages/ses/index.d.ts
packages/ses/index.d.ts
+/* eslint-disable no-restricted-globals */
// It's academically tempting to define a hardened type, but TypeScript doesn't
// strike a good balance in distinguishing "readonly" in the sense that you
@@ -31,8 +32,8 @@ export interface LockdownOptions {
export type Lockdown = (options?: LockdownOptions) => void;
-export type __LiveExportsMap__ = Record<string, [string, boolean]>
-export type __FixedExportsMap__ = Record<string, [string]>
+export type __LiveExportsMap__ = Record<string, [string, boolean]>;
+export type __FixedExportsMap__ = Record<string, [string]>;
export interface PrecompiledStaticModuleInterface {
imports: Array<string>;
@@ -46,33 +47,46 @@ export interface PrecompiledStaticModuleInterface {
export interface ThirdPartyStaticModuleInterface {
imports: Array<string>;
exports: Array<string>;
- execute(proxiedExports: Object, compartment: Compartment, resolvedImports: Record<string, string>): void;
+ execute(
+ proxiedExports: Object,
+ compartment: Compartment,
+ resolvedImports: Record<string, string>,
+ ): void;
}
-export type FinalStaticModuleType = PrecompiledStaticModuleInterface | ThirdPartyStaticModuleInterface
+export type FinalStaticModuleType =
+ | PrecompiledStaticModuleInterface
+ | ThirdPartyStaticModuleInterface;
export interface RedirectStaticModuleInterface {
- record: FinalStaticModuleType,
- specifier: string
+ record: FinalStaticModuleType;
+ specifier: string;
}
-export type StaticModuleType = RedirectStaticModuleInterface | FinalStaticModuleType
+export type StaticModuleType =
+ | RedirectStaticModuleInterface
+ | FinalStaticModuleType;
-export type ModuleExportsNamespace = Record<string, any>
+export type ModuleExportsNamespace = Record<string, any>;
export type Transform = (source: string) => string;
-export type ResolveHook = (importSpecifier: string, referrerSpecifier: string) => string;
+export type ResolveHook = (
+ importSpecifier: string,
+ referrerSpecifier: string,
+) => string;
export type ModuleMap = Record<string, string | ModuleExportsNamespace>;
-export type ModuleMapHook = (moduleSpecifier: string) => string | ModuleExportsNamespace | void;
+export type ModuleMapHook = (
+ moduleSpecifier: string,
+) => string | ModuleExportsNamespace | void;
export type ImportHook = (moduleSpecifier: string) => Promise<StaticModuleType>;
export interface CompartmentOptions {
name?: string;
transforms?: Array<Transform>;
globalLexicals?: Record<string, any>;
- moduleMapHook?: ModuleMapHook,
- importHook?: ImportHook,
- resolveHook?: ResolveHook,
+ moduleMapHook?: ModuleMapHook;
+ importHook?: ImportHook;
+ resolveHook?: ResolveHook;
__shimTransforms__?: Array<Transform>;
}
@@ -85,21 +99,53 @@ export interface EvaluateOptions {
}
// The DetailsToken is an empty object literal.
-export type DetailsToken = Record<any, never>
-export type Details = string | DetailsToken
+export type DetailsToken = Record<any, never>;
+export type Details = string | DetailsToken;
export interface AssertMakeErrorOptions {
- errorName?: string,
+ errorName?: string;
}
-type AssertTypeofBigint = (specimen: any, typeName: 'bigint', details?: Details) => asserts specimen is bigint;
-type AssertTypeofBoolean = (specimen: any, typeName: 'boolean', details?: Details) => asserts specimen is boolean;
-type AssertTypeofFunction = (specimen: any, typeName: 'function', details?: Details) => asserts specimen is Function;
-type AssertTypeofNumber = (specimen: any, typeName: 'number', details?: Details) => asserts specimen is number;
-type AssertTypeofObject = (specimen: any, typeName: 'object', details?: Details) => asserts specimen is Record<any, any> | null;
-type AssertTypeofString = (specimen: any, typeName: 'string', details?: Details) => asserts specimen is string;
-type AssertTypeofSymbol = (specimen: any, typeName: 'symbol', details?: Details) => asserts specimen is symbol;
-type AssertTypeofUndefined = (specimen: any, typeName: 'undefined', details?: Details) => asserts specimen is undefined;
+type AssertTypeofBigint = (
+ specimen: any,
+ typeName: 'bigint',
+ details?: Details,
+) => asserts specimen is bigint;
+type AssertTypeofBoolean = (
+ specimen: any,
+ typeName: 'boolean',
+ details?: Details,
+) => asserts specimen is boolean;
+type AssertTypeofFunction = (
+ specimen: any,
+ typeName: 'function',
+ details?: Details,
+) => asserts specimen is Function;
+type AssertTypeofNumber = (
+ specimen: any,
+ typeName: 'number',
+ details?: Details,
+) => asserts specimen is number;
+type AssertTypeofObject = (
+ specimen: any,
+ typeName: 'object',
+ details?: Details,
+) => asserts specimen is Record<any, any> | null;
+type AssertTypeofString = (
+ specimen: any,
+ typeName: 'string',
+ details?: Details,
+) => asserts specimen is string;
+type AssertTypeofSymbol = (
+ specimen: any,
+ typeName: 'symbol',
+ details?: Details,
+) => asserts specimen is symbol;
+type AssertTypeofUndefined = (
+ specimen: any,
+ typeName: 'undefined',
+ details?: Details,
+) => asserts specimen is undefined;
export type AssertTypeof = AssertTypeofBigint &
AssertTypeofBoolean &
@@ -110,45 +156,74 @@ export type AssertTypeof = AssertTypeofBigint &
AssertTypeofSymbol &
AssertTypeofUndefined;
-export type Raise = (reason: Error) => void;
-export type MakeAssert = (raise?: Raise, unredacted?: boolean) => Assert;
-
interface ToStringable {
- toString(): string
+ toString(): string;
}
+export type Raise = (reason: Error) => void;
+// Behold: recursion.
+// eslint-disable-next-line no-use-before-define
+export type MakeAssert = (raise?: Raise, unredacted?: boolean) => Assert;
+
export interface Assert {
- (value: any, details?: Details, errorConstructor?:ErrorConstructor): asserts value;
- typeof: AssertTypeof,
- error(details?: Details, errorConstructor?:ErrorConstructor, options?:AssertMakeErrorOptions): Error;
+ (
+ value: any,
+ details?: Details,
+ errorConstructor?: ErrorConstructor,
+ ): asserts value;
+ typeof: AssertTypeof;
+ error(
+ details?: Details,
+ errorConstructor?: ErrorConstructor,
+ options?: AssertMakeErrorOptions,
+ ): Error;
fail(details?: Details, errorConstructor?: ErrorConstructor): never;
- equal(left: any, right: any, details?: Details, errorConstructor?:ErrorConstructor): void;
+ equal(
+ left: any,
+ right: any,
+ details?: Details,
+ errorConstructor?: ErrorConstructor,
+ ): void;
string(specimen: any, details?: Details): asserts specimen is string;
note(error: Error, details: Details): void;
- details(template: TemplateStringsArray | string[], ...args: any): DetailsToken,
- quote(payload: any, spaces?: string|number): ToStringable,
- makeAssert: MakeAssert,
+ details(
+ template: TemplateStringsArray | string[],
+ ...args: any
+ ): DetailsToken;
+ quote(payload: any, spaces?: string | number): ToStringable;
+ makeAssert: MakeAssert;
}
declare global {
- var harden: Harden;
+ const harden: Harden;
- var lockdown: Lockdown;
+ const lockdown: Lockdown;
- var assert: Assert;
+ const assert: Assert;
/**
* Each Compartment constructor is a global. A host that wants to execute
* code in a context bound to a new global creates a new compartment.
*/
export class Compartment {
- constructor(globals?: Object, moduleMap?: ModuleMap, options?:CompartmentOptions);
+ constructor(
+ globals?: Object,
+ moduleMap?: ModuleMap,
+ options?: CompartmentOptions,
+ );
+
get globalThis(): Record<string, any>;
+
get name(): string;
+
evaluate(code: string): any;
+
import(specifier: string): Promise<{ namespace: ModuleExportsNamespace }>;
+
load(specifier: string): Promise<void>;
+
importNow(specifier: string): ModuleExportsNamespace;
+
module(specifier: string): ModuleExportsNamespace;
}
}

MODIFY
packages/ses/src/lockdown-shim.js
packages/ses/src/lockdown-shim.js
@@ -229,11 +229,14 @@ export const repairIntrinsics = (options = {}) => {
const seemsToBeLockedDown = () => {
return (
globalThis.Function.prototype.constructor !== globalThis.Function &&
+ // @ts-ignore harden is absent on globalThis type def.
typeof globalThis.harden === 'function' &&
+ // @ts-ignore lockdown is absent on globalThis type def.
typeof globalThis.lockdown === 'function' &&
globalThis.Date.prototype.constructor !== globalThis.Date &&
typeof globalThis.Date.now === 'function' &&
- // @ts-ignore
+ // @ts-ignore does not recognize that Date constructor is a special
+ // Function.
// eslint-disable-next-line @endo/no-polymorphic-call
is(globalThis.Date.prototype.constructor.now(), NaN)
);
@@ -289,12 +292,14 @@ export const repairIntrinsics = (options = {}) => {
);
globalThis.console = /** @type {Console} */ (consoleRecord.console);
+ // @ts-ignore assert is absent on globalThis type def.
if (errorTaming === 'unsafe' && globalThis.assert === assert) {
// If errorTaming is 'unsafe' we replace the global assert with
// one whose `details` template literal tag does not redact
// unmarked substitution values. IOW, it blabs information that
// was supposed to be secret from callers, as an aid to debugging
// at a further cost in safety.
+ // @ts-ignore assert is absent on globalThis type def.
globalThis.assert = makeAssert(undefined, true);
}
@@ -359,6 +364,7 @@ export const repairIntrinsics = (options = {}) => {
// that is portable between JS and SES), the existence of harden in global
// scope signals whether such code should attempt to use harden in the
// defense of its own API.
+ // @ts-ignore harden not yet recognized on globalThis.
globalThis.harden = harden;
// Returning `true` indicates that this is a JS to SES transition.

MODIFY
packages/static-module-record/index.d.ts
packages/static-module-record/index.d.ts
-import type { PrecompiledStaticModuleInterface } from 'ses';
+/* eslint-disable no-restricted-globals */
+import {
+ PrecompiledStaticModuleInterface,
+ __LiveExportsMap__,
+ __FixedExportsMap__,
+} from 'ses';
export class StaticModuleRecord implements PrecompiledStaticModuleInterface {
constructor(source: string, location?: string);
+
imports: Array<string>;
+
exports: Array<string>;
+
reexports: Array<string>;
+
__syncModuleProgram__: string;
+
__liveExportsMap__: __LiveExportsMap__;
+
__fixedExportsMap__: __FixedExportsMap__;
}

MODIFY
packages/static-module-record/package.json
packages/static-module-record/package.json
"test": "ava"
},
"dependencies": {
- "@agoric/babel-standalone": "^7.14.3"
+ "@agoric/babel-standalone": "^7.14.3",
+ "ses": "^0.15.4"
},
"devDependencies": {
"@ava/babel": "^1.0.1",
"eslint-plugin-import": "^2.19.1",
"eslint-plugin-prettier": "^3.1.2",
"prettier": "^1.19.1",
- "ses": "^0.15.4",
"typescript": "^4.0.5"
},
"files": [

MODIFY
packages/stream-types-test/validation.ts
packages/stream-types-test/validation.ts
-/* eslint-disable no-unused-vars, no-underscore-dangle, no-empty */
+/* eslint-disable no-underscore-dangle, no-empty */
/// <reference types="ses"/>
import { makeQueue, makeStream, makePipe, pump, prime, mapReader, mapWriter } from '@endo/stream';

MODIFY
packages/stream/index.d.ts
packages/stream/index.d.ts
-/* eslint-disable no-unused-vars, import/no-unresolved */
import { AsyncQueue, Stream } from './types.js';
export * from './types.js';

MODIFY
packages/stream/types.d.ts
packages/stream/types.d.ts
-/* eslint-disable no-unused-vars */
-
export interface AsyncQueue<TValue> {
put(value: TValue | Promise<TValue>): void;
get(): Promise<TValue>;

MODIFY
packages/where/types.d.ts
packages/where/types.d.ts
-export function whereEndo(platform: string, env: {[name: string]: string}): string;
-export function whereEndoSock(platform: string, env: {[name: string]: string}): string;
-export function whereEndoLog(platform: string, env: {[name: string]: string}): string;
-
+export function whereEndo(
+ platform: string,
+ env: { [name: string]: string },
+): string;
+export function whereEndoSock(
+ platform: string,
+ env: { [name: string]: string },
+): string;
+export function whereEndoLog(
+ platform: string,
+ env: { [name: string]: string },
+): string;

style: Lint TypeScript