{"record":{"id":"31376833355369db","repo":"facebook/relay","slug":"expected-the-js-type-for-to-be-defined-pleas","errorCode":null,"errorMessage":"Expected the JS type for '{}' to be defined, please update 'customScalarTypes' in your compiler config.","messagePattern":"Expected the JS type for '(.+?)' to be defined, please update 'customScalarTypes' in your compiler config\\.","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"compiler/crates/relay-typegen/src/visit.rs","lineNumber":2353,"sourceCode":"            CustomType::Path(CustomTypeImport { name, path }) => {\n                custom_scalars.insert((*name, path.clone()));\n\n                AST::RawType(*name)\n            }\n        }\n    } else if scalar_name.item == *TYPE_ID || scalar_name.item == *TYPE_STRING {\n        AST::String\n    } else if scalar_name.item == *TYPE_FLOAT || scalar_name.item == *TYPE_INT {\n        AST::Number\n    } else if scalar_name.item == *TYPE_BOOLEAN {\n        AST::Boolean\n    } else {\n        if typegen_context\n            .project_config\n            .typegen_config\n            .require_custom_scalar_types\n        {\n            panic!(\n                \"Expected the JS type for '{}' to be defined, please update 'customScalarTypes' in your compiler config.\",\n                scalar_name.item\n            );\n        }\n        AST::Any\n    }\n}\n\nfn transform_graphql_enum_type(\n    schema: &SDLSchema,\n    enum_id: EnumID,\n    encountered_enums: &mut EncounteredEnums,\n) -> AST {\n    encountered_enums.0.insert(enum_id);\n    AST::Identifier(schema.enum_(enum_id).name.item.0)\n}\n\n#[allow(clippy::too_many_arguments)]","sourceCodeStart":2335,"sourceCodeEnd":2371,"githubUrl":"https://github.com/facebook/relay/blob/668b1b85e06261aa3b58dabfc51f8b5524a70955/compiler/crates/relay-typegen/src/visit.rs#L2335-L2371","documentation":"For custom scalars, typegen must map the GraphQL scalar to a JS type via customScalarTypes. When the mapping is missing and the project's typegen config sets require_custom_scalar_types, the compiler panics, telling you to declare the JS type in your compiler config.","triggerScenarios":"transform_graphql_scalar_type resolves a scalar whose name is absent from the customScalarTypes mapping, with project_config.typegen_config.require_custom_scalar_types == true; triggered from transform_non_nullable_input_type / expect_scalar_type / return_ast_in_object_case.","commonSituations":"Adding a new custom scalar to the schema without updating customScalarTypes in relay.config; enabling require_custom_scalar_types in a project with legacy unmapped scalars; typos between the schema scalar name and the config key.","solutions":["Add the scalar to customScalarTypes in your relay compiler config with its JS type path/export.","Confirm the config key exactly matches the schema scalar name (case-sensitive).","Set require_custom_scalar_types: false only as a temporary measure to fall back to Any.","Regenerate with the updated config and verify all custom scalars are covered."],"exampleFix":"// relay.config.js before\ncustomScalarTypes: {},\n// after\ncustomScalarTypes: {\n  DateTime: { path: './src/types/DateTime.ts', export: 'DateTime' },\n},","handlingStrategy":"validation","validationCode":"// ensure every schema custom scalar has a JS type mapping\nfor (const scalar of getCustomScalars(schema)) {\n  if (!config.customScalarTypes[scalar.name]) throw new Error(`Missing customScalarTypes entry for ${scalar.name}`);\n}","typeGuard":"const isMappedScalar = (name, cfg) => Object.prototype.hasOwnProperty.call(cfg.customScalarTypes ?? {}, name);","tryCatchPattern":null,"preventionTips":["Add a customScalarTypes entry whenever a new custom scalar is added to the schema","Keep schema scalar names and config keys in a shared, tested list","Run relay-compiler in CI with require_custom_scalar_types enabled to catch gaps early"],"tags":["typegen","custom-scalar","config","panic"],"backgroundTag":"missing-config-mapping","analyzedSha":"668b1b85e06261aa3b58dabfc51f8b5524a70955","analyzedAt":"2026-09-02T19:57:20.783Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}