Skip to content

Missing explicit type on non-exported symbol? #598

Open
@greggman

Description

@greggman

I have code something like this

// things.ts
export type ThingDef = {
    size: number;
};

const createThingDefs = <T extends Record<string, ThingDef>>(defs: T): { readonly [K in keyof T]: ThingDef } => defs;

export const kThingInfo = createThingDefs({
  bear: { size: 20 },
  chicken: { size: 1 },
} as const);

export type ThingType = keyof typeof kThingInfo;
// index.ts
import { kThingInfo, ThingType } from './things.js';

export { ThingType };

export function getThingSize(type: ThingType): number {
  return kThingInfo[type].size;
}

The only things I want to export is the type ThingType and getThingSize but jsr complains about kThingInfo even though AFAICT it's not public and shouldn't need to be

❯ npx jsr publish --dry-run
Checking for slow types in the public API...
error[missing-explicit-type]: missing explicit type in the public API
 --> /Users/gman/temp/delme-jsr-test/things.ts:7:14
  |
7 | export const kThingInfo = createThingDefs({
  |              ^^^^^^^^^^ 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

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    Status

    Ready

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions