An experimental TypeSpec syntax for Lexicon
56
fork

Configure Feed

Select the types of activity you want to include in your feed.

wip

+27
+27
packages/emitter/src/emitter.ts
··· 1227 1227 1228 1228 // Otherwise, emit as union of refs 1229 1229 if (unionRefs.length > 0) { 1230 + // Check for unsupported mixed pattern: model refs + string literals 1231 + if (stringLiterals.length > 0) { 1232 + this.program.reportDiagnostic({ 1233 + code: "union-mixed-refs-literals", 1234 + severity: "error", 1235 + message: 1236 + `Union contains both model references and string literals. Atproto unions must be either: ` + 1237 + `(1) model references only (type: "union"), or ` + 1238 + `(2) string literals + string type (type: "string" with knownValues). ` + 1239 + `Separate these into distinct fields or nested unions.`, 1240 + target: unionType, 1241 + }); 1242 + return null; 1243 + } 1244 + 1230 1245 const unionDef: LexiconUnion = { 1231 1246 type: "union", 1232 1247 refs: unionRefs, ··· 1256 1271 } 1257 1272 return unionDef; 1258 1273 } 1274 + 1275 + // No refs and no string literals - empty or unsupported union 1276 + if (stringLiterals.length === 0 && !hasUnknown) { 1277 + this.program.reportDiagnostic({ 1278 + code: "union-empty", 1279 + severity: "error", 1280 + message: 1281 + `Union has no variants. Atproto unions must contain either model references or string literals.`, 1282 + target: unionType, 1283 + }); 1284 + } 1285 + 1259 1286 return null; 1260 1287 case "Intrinsic": 1261 1288 // Handle unknown type - return unknown definition