Compare commits
No commits in common. "f101c1209715fcf399561d0dbf8d3751071e6bd7" and "1061e12c81b6afc3d24926ad4c27b78c076f0e8b" have entirely different histories.
f101c12097
...
1061e12c81
|
|
@ -1,7 +0,0 @@
|
|||
# type IntentEffectTarget = 'user' | 'eachEnemy' | 'randomEnemy' | 'player'
|
||||
# type IntentEffect = [IntentEffectTarget; string; number]
|
||||
# type IntentEffects = IntentEffect[]
|
||||
|
||||
id,enemy,initialIntent,nextIntents,brokenIntent,effects
|
||||
string,string,boolean,string[],string[],IntentEffects
|
||||
仙人掌怪-boost,仙人掌怪,true,仙人掌怪-boost;仙人掌怪-defend,,[user;spike;1];[user;defend;4]
|
||||
|
|
|
@ -207,28 +207,4 @@ describe("parseCsv - references in combinatory schemas", () => {
|
|||
],
|
||||
]);
|
||||
});
|
||||
|
||||
it("should parse enemy_intents fixture with tuple arrays and type aliases", () => {
|
||||
const enemyIntentsCsv = readFixture("enemy_intents.csv");
|
||||
|
||||
const result = parseCsv(enemyIntentsCsv, {
|
||||
emitTypes: false,
|
||||
currentFilePath: path.join(fixturesDir, "enemy_intents.csv"),
|
||||
});
|
||||
|
||||
expect(result.data).toHaveLength(1);
|
||||
|
||||
expect(result.data[0]).toMatchObject({
|
||||
id: "仙人掌怪-boost",
|
||||
enemy: "仙人掌怪",
|
||||
initialIntent: true,
|
||||
nextIntents: ["仙人掌怪-boost", "仙人掌怪-defend"],
|
||||
brokenIntent: [],
|
||||
});
|
||||
|
||||
const effects = result.data[0].effects as unknown[][];
|
||||
expect(effects).toHaveLength(2);
|
||||
expect(effects[0]).toEqual(["user", "spike", 1]);
|
||||
expect(effects[1]).toEqual(["user", "defend", 4]);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -85,14 +85,6 @@ function expandSchemaInString(
|
|||
return expanded;
|
||||
}
|
||||
|
||||
// Handle array suffix: TypeName[] or [tuple][]
|
||||
const trimmed = schemaString.trim();
|
||||
if (trimmed.endsWith("[]")) {
|
||||
const inner = trimmed.slice(0, -2);
|
||||
const expandedInner = expandSchemaInString(inner, declaredTypes);
|
||||
return `${expandedInner}[]`;
|
||||
}
|
||||
|
||||
// Handle union types (recursively expand each member)
|
||||
if (schemaString.includes("|")) {
|
||||
// Split by | but respect quotes
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ export function generateTypeDefinition(
|
|||
? typeDeclarations
|
||||
.map(
|
||||
(decl) =>
|
||||
`export type ${decl.name} = ${schemaToTypeString(decl.schema, resourceNames)};`,
|
||||
`type ${decl.name} = ${schemaToTypeString(decl.schema, resourceNames)};`,
|
||||
)
|
||||
.join("\n") + "\n\n"
|
||||
: "";
|
||||
|
|
|
|||
Loading…
Reference in New Issue