nbd-wtf / nostr-tools

Tools for developing Nostr clients.
The Unlicense
685 stars 188 forks source link

Slow types #375

Closed alexgleason closed 6 months ago

alexgleason commented 6 months ago

Publishing to JSR, it detects these slow types:

Check file:///home/alex/Projects/nostr-tools/index.ts
Checking for slow types in the public API...
error[missing-explicit-return-type]: missing explicit return type in the public API
  --> /home/alex/Projects/nostr-tools/abstract-relay.ts:47:16
   | 
47 |   static async connect(url: string, opts: { verifyEvent: Nostr['verifyEvent'] }) {
   |                ^^^^^^^ this function is missing an explicit return type
   = hint: add an explicit return type to the function

  info: all functions in the public API must have an explicit return type
  docs: https://jsr.io/go/slow-type-missing-explicit-return-type

error[missing-explicit-return-type]: missing explicit return type in the public API
   --> /home/alex/Projects/nostr-tools/abstract-relay.ts:231:16
    | 
231 |   public async auth(signAuthEvent: (evt: EventTemplate) => Promise<VerifiedEvent>) {
    |                ^^^^ this function is missing an explicit return type
    = hint: add an explicit return type to the function

  info: all functions in the public API must have an explicit return type
  docs: https://jsr.io/go/slow-type-missing-explicit-return-type

error[missing-explicit-return-type]: missing explicit return type in the public API
 --> /home/alex/Projects/nostr-tools/kinds.ts:2:17
  | 
2 | export function isRegularKind(kind: number) {
  |                 ^^^^^^^^^^^^^ this function is missing an explicit return type
  = hint: add an explicit return type to the function

  info: all functions in the public API must have an explicit return type
  docs: https://jsr.io/go/slow-type-missing-explicit-return-type

error[missing-explicit-return-type]: missing explicit return type in the public API
 --> /home/alex/Projects/nostr-tools/kinds.ts:7:17
  | 
7 | export function isReplaceableKind(kind: number) {
  |                 ^^^^^^^^^^^^^^^^^ this function is missing an explicit return type
  = hint: add an explicit return type to the function

  info: all functions in the public API must have an explicit return type
  docs: https://jsr.io/go/slow-type-missing-explicit-return-type

error[missing-explicit-return-type]: missing explicit return type in the public API
  --> /home/alex/Projects/nostr-tools/kinds.ts:12:17
   | 
12 | export function isEphemeralKind(kind: number) {
   |                 ^^^^^^^^^^^^^^^ this function is missing an explicit return type
   = hint: add an explicit return type to the function

  info: all functions in the public API must have an explicit return type
  docs: https://jsr.io/go/slow-type-missing-explicit-return-type

error[missing-explicit-return-type]: missing explicit return type in the public API
  --> /home/alex/Projects/nostr-tools/kinds.ts:17:17
   | 
17 | export function isParameterizedReplaceableKind(kind: number) {
   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this function is missing an explicit return type
   = hint: add an explicit return type to the function

  info: all functions in the public API must have an explicit return type
  docs: https://jsr.io/go/slow-type-missing-explicit-return-type

error[missing-explicit-return-type]: missing explicit return type in the public API
  --> /home/alex/Projects/nostr-tools/nip11.ts:11:23
   | 
11 | export async function fetchRelayInformation(url: string) {
   |                       ^^^^^^^^^^^^^^^^^^^^^ this function is missing an explicit return type
   = hint: add an explicit return type to the function

  info: all functions in the public API must have an explicit return type
  docs: https://jsr.io/go/slow-type-missing-explicit-return-type

error[missing-explicit-return-type]: missing explicit return type in the public API
 --> /home/alex/Projects/nostr-tools/nip27.ts:5:14
  | 
5 | export const regex = () => new RegExp(`\\b${NOSTR_URI_REGEX.source}\\b`, 'g')
  |              ^^^^^ this function is missing an explicit return type
  = hint: add an explicit return type to the function

  info: all functions in the public API must have an explicit return type
  docs: https://jsr.io/go/slow-type-missing-explicit-return-type

error[missing-explicit-return-type]: missing explicit return type in the public API
 --> /home/alex/Projects/nostr-tools/nip30.ts:5:14
  | 
5 | export const regex = () => new RegExp(`\\B${EMOJI_SHORTCODE_REGEX.source}\\B`, 'g')
  |              ^^^^^ this function is missing an explicit return type
  = hint: add an explicit return type to the function

  info: all functions in the public API must have an explicit return type
  docs: https://jsr.io/go/slow-type-missing-explicit-return-type

error[missing-explicit-return-type]: missing explicit return type in the public API
 --> /home/alex/Projects/nostr-tools/nip47.ts:5:17
  | 
5 | export function parseConnectionString(connectionString: string) {
  |                 ^^^^^^^^^^^^^^^^^^^^^ this function is missing an explicit return type
  = hint: add an explicit return type to the function

  info: all functions in the public API must have an explicit return type
  docs: https://jsr.io/go/slow-type-missing-explicit-return-type

error[missing-explicit-return-type]: missing explicit return type in the public API
  --> /home/alex/Projects/nostr-tools/nip47.ts:18:23
   | 
18 | export async function makeNwcRequestEvent(pubkey: string, secretKey: Uint8Array, invoice: string) {
   |                       ^^^^^^^^^^^^^^^^^^^ this function is missing an explicit return type
   = hint: add an explicit return type to the function

  info: all functions in the public API must have an explicit return type
  docs: https://jsr.io/go/slow-type-missing-explicit-return-type

error[missing-explicit-return-type]: missing explicit return type in the public API
  --> /home/alex/Projects/nostr-tools/relay.ts:16:16
   | 
16 |   static async connect(url: string) {
   |                ^^^^^^^ this function is missing an explicit return type
   = hint: add an explicit return type to the function

  info: all functions in the public API must have an explicit return type
  docs: https://jsr.io/go/slow-type-missing-explicit-return-type

error[missing-explicit-return-type]: missing explicit return type in the public API
  --> /home/alex/Projects/nostr-tools/utils.ts:17:17
   | 
17 | export function insertEventIntoDescendingList(sortedArray: Event[], event: Event) {
   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this function is missing an explicit return type
   = hint: add an explicit return type to the function

  info: all functions in the public API must have an explicit return type
  docs: https://jsr.io/go/slow-type-missing-explicit-return-type

error[missing-explicit-return-type]: missing explicit return type in the public API
  --> /home/alex/Projects/nostr-tools/utils.ts:29:17
   | 
29 | export function insertEventIntoAscendingList(sortedArray: Event[], event: Event) {
   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this function is missing an explicit return type
   = hint: add an explicit return type to the function

  info: all functions in the public API must have an explicit return type
  docs: https://jsr.io/go/slow-type-missing-explicit-return-type

error[missing-explicit-type]: missing explicit type in the public API
  --> /home/alex/Projects/nostr-tools/abstract-pool.ts:18:10
   | 
18 |   public seenOn = new Map<string, Set<AbstractRelay>>()
   |          ^^^^^^ this symbol is missing an explicit type
   = hint: add an explicit type annotation to the symbol

  info: all symbols in the public API must have an explicit type
  docs: https://jsr.io/go/slow-type-missing-explicit-type

error[missing-explicit-type]: missing explicit type in the public API
  --> /home/alex/Projects/nostr-tools/abstract-pool.ts:22:10
   | 
22 |   public trustedRelayURLs = new Set<string>()
   |          ^^^^^^^^^^^^^^^^ this symbol is missing an explicit type
   = hint: add an explicit type annotation to the symbol

  info: all symbols in the public API must have an explicit type
  docs: https://jsr.io/go/slow-type-missing-explicit-type

error[missing-explicit-type]: missing explicit type in the public API
  --> /home/alex/Projects/nostr-tools/abstract-relay.ts:29:10
   | 
29 |   public openSubs = new Map<string, Subscription>()
   |          ^^^^^^^^ this symbol is missing an explicit type
   = hint: add an explicit type annotation to the symbol

  info: all symbols in the public API must have an explicit type
  docs: https://jsr.io/go/slow-type-missing-explicit-type

error[missing-explicit-type]: missing explicit type in the public API
 --> /home/alex/Projects/nostr-tools/nip21.ts:4:14
  | 
4 | export const NOSTR_URI_REGEX = new RegExp(`nostr:(${BECH32_REGEX.source})`)
  |              ^^^^^^^^^^^^^^^ this symbol is missing an explicit type
  = hint: add an explicit type annotation to the symbol

  info: all symbols in the public API must have an explicit type
  docs: https://jsr.io/go/slow-type-missing-explicit-type

error[missing-explicit-type]: missing explicit type in the public API
  --> /home/alex/Projects/nostr-tools/nip44.ts:11:7
   | 
11 | const u = {
   |       ^ this symbol is missing an explicit type
   = hint: add an explicit type annotation to the symbol

  info: all symbols in the public API must have an explicit type
  docs: https://jsr.io/go/slow-type-missing-explicit-type

error[missing-explicit-type]: missing explicit type in the public API
   --> /home/alex/Projects/nostr-tools/nip44.ts:106:66
    | 
106 | function encrypt(plaintext: string, conversationKey: Uint8Array, nonce = randomBytes(32)): string {
    |                                                                  ^^^^^ this symbol is missing an explicit type
    = hint: add an explicit type annotation to the symbol

  info: all symbols in the public API must have an explicit type
  docs: https://jsr.io/go/slow-type-missing-explicit-type

error[missing-explicit-type]: missing explicit type in the public API
  --> /home/alex/Projects/nostr-tools/pure.ts:53:7
   | 
53 | const i = new JS()
   |       ^ this symbol is missing an explicit type
   = hint: add an explicit type annotation to the symbol

  info: all symbols in the public API must have an explicit type
  docs: https://jsr.io/go/slow-type-missing-explicit-type

error[missing-explicit-type]: missing explicit type in the public API
 --> /home/alex/Projects/nostr-tools/utils.ts:3:14
  | 
3 | export const utf8Decoder = new TextDecoder('utf-8')
  |              ^^^^^^^^^^^ this symbol is missing an explicit type
  = hint: add an explicit type annotation to the symbol

  info: all symbols in the public API must have an explicit type
  docs: https://jsr.io/go/slow-type-missing-explicit-type

error[missing-explicit-type]: missing explicit type in the public API
 --> /home/alex/Projects/nostr-tools/utils.ts:4:14
  | 
4 | export const utf8Encoder = new TextEncoder()
  |              ^^^^^^^^^^^ this symbol is missing an explicit type
  = hint: add an explicit type annotation to the symbol

  info: all symbols in the public API must have an explicit type
  docs: https://jsr.io/go/slow-type-missing-explicit-type

This package contains errors for slow types. Fixing these errors will:

  1. Significantly improve your package users' type checking performance.
  2. Improve the automatic documentation generation.
  3. Enable automatic .d.ts generation for Node.js.

Don't want to bother? You can choose to skip this step by
providing the --allow-slow-types flag.

error: Found 23 problems