{"record":{"id":"92f8213c4a1b36d3","repo":"clockworklabs/SpacetimeDB","slug":"schema-entry-accname-looks-like-a-default-imp","errorCode":null,"errorMessage":"schema entry '${accName}' looks like a default import; use `import * as ${accName} from '...'` so the submodule can see the library's named reducer exports.","messagePattern":"schema entry '(.+?)' looks like a default import; use `import \\* as (.+?) from '\\.\\.\\.'` so the submodule can see the library's named reducer exports\\.","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"crates/bindings-typescript/src/server/schema.ts","lineNumber":855,"sourceCode":"  const H extends Record<string, SchemaEntry>,\n  const E extends EnvironmentSchema = {},\n>(\n  entries: H,\n  moduleSettings?: ModuleSettings<E>\n): Schema<SchemaDefForEntries<H> & { env: E }> {\n  const ctx = new SchemaInner<SchemaDefForEntries<H> & { env: E }>(ctx => {\n    ctx.moduleDef.environment = environmentDeclarations(\n      moduleSettings?.env ?? {}\n    );\n    // Apply module settings.\n    if (moduleSettings?.CASE_CONVERSION_POLICY != null) {\n      ctx.setCaseConversionPolicy(moduleSettings.CASE_CONVERSION_POLICY);\n    }\n\n    const tableSchemas: Record<string, UntypedTableDef> = {};\n    for (const [accName, entry] of Object.entries(entries)) {\n      if (entry instanceof Schema) {\n        throw new TypeError(\n          `schema entry '${accName}' looks like a default import; use \\`import * as ${accName} from '...'\\` so the submodule can see the library's named reducer exports.`\n        );\n      }\n      if (isSubmoduleNamespace(entry)) {\n        const { rawDef, dispatch } =\n          entry.default.buildSubmoduleDispatch(entry);\n        dispatch.namespace = accName;\n        ctx.addSubmodule({ namespace: accName, module: rawDef });\n        ctx.submoduleDispatchInfos.push(dispatch);\n        continue;\n      }\n      if (!isUntypedTableSchema(entry)) {\n        throw new TypeError(\n          `schema entry '${accName}' must be a table or a submodule namespace object`\n        );\n      }\n\n      const table = entry;","sourceCodeStart":837,"sourceCodeEnd":873,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/eddf9f5014579a50d4b67630e28b6e15cad9c4af/crates/bindings-typescript/src/server/schema.ts#L837-L873","documentation":"Entries in the object passed to `schema({...})` must be tables or submodule namespace objects. If an entry is itself a `Schema` instance (`entry instanceof Schema`), the usual cause is a default import of a library module (`import Lib from 'lib'` yields the schema) used directly as an entry. The error message is prescriptive: re-import as a namespace so the schema can see and register the library's named reducer exports.","triggerScenarios":"`import scheduledLib from '../lib'; export default schema({ scheduledLib })` where the library's default export is a `Schema`; mixing up the library's default export (schema) with its namespace (tables + reducers); refactoring an import from `import * as x` to `import x` during a cleanup.","commonSituations":"Integrating a shared spacetime library as a submodule; auto-fix/'add missing imports' switching to a default import; copy-pasting integration snippets with the wrong import style.","solutions":["Change to a namespace import: `import * as scheduledLib from '../lib';` and keep `schema({ scheduledLib })`.","Make sure the library file has named exports for its reducers/tables; the schema entry must be the namespace object, not the library's default export.","If the entry should be a table, pass the `table()` handle directly instead of the module/schema object."],"exampleFix":"// before\nimport scheduledLib from '../lib'; // default import = Schema instance\nexport default schema({ users, scheduledLib }); // TypeError\n\n// after\nimport * as scheduledLib from '../lib';\nexport default schema({ users, scheduledLib });","handlingStrategy":"type-guard","validationCode":"// Normalize schema entries: reject Schema instances before calling schema().\nimport { Schema } from '...';\nfunction assertEntries(entries: Record<string, unknown>) {\n  for (const [name, entry] of Object.entries(entries)) {\n    if (entry instanceof Schema) throw new Error(`${name} is a Schema; use a namespace import`);\n  }\n}","typeGuard":"function isSchemaInstance(x: unknown): x is Schema { return x instanceof Schema; }","tryCatchPattern":null,"preventionTips":["Use `import * as lib from 'lib'` for any module passed as a schema entry.","Watch for auto-import quick-fixes that silently switch namespace imports to default imports.","Keep the library's default export for external consumers, but never feed it to schema()."],"tags":["schema","imports","modules","build-time","spacetimedb","typescript"],"backgroundTag":"default-import-misuse","analyzedSha":"eddf9f5014579a50d4b67630e28b6e15cad9c4af","analyzedAt":"2026-08-20T06:08:37.179Z","contentChangedAt":"2026-08-20T06:08:37.179Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}