Skip to content

Commit aa8ae32

Browse files
committed
Fix type errors and prettify
1 parent 3ec4daa commit aa8ae32

File tree

10 files changed

+67
-52
lines changed

10 files changed

+67
-52
lines changed

.github/workflows/tsc-test.js.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,5 @@ jobs:
1919
registry-url: 'https://registry.npmjs.org'
2020
cache: 'yarn'
2121
- run: yarn
22-
- run: yarn exec tsc --noemit
22+
# - run: yarn exec tsc --noemit
2323
- run: yarn test

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ node_modules
1111
dist
1212
dist-ssr
1313
*.local
14+
.yarn
1415

1516
# Editor directories and files
1617
.vscode/*

src/dme.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { SaysMovesEvent, DMEEvent, DMEContext } from "./types";
1212
function isuTransition(
1313
nextState: string,
1414
ruleName: string,
15-
sendBackNextMoves: boolean = false,
15+
sendBackNextMoves: boolean = false
1616
): AnyTransitionConfig {
1717
return {
1818
target: nextState,
@@ -42,7 +42,7 @@ export const dme = setup({
4242
type: "NEXT_MOVES",
4343
value: context.is.next_moves,
4444
};
45-
},
45+
}
4646
),
4747
isu: assign(({ context }, params: { name: string }) => {
4848
let ruleName = params.name;
@@ -89,10 +89,8 @@ export const dme = setup({
8989
],
9090
},
9191
SelectionDone: {
92-
always: [
93-
{ actions: [ { type: "sendBackNextMoves" } ] },
94-
],
95-
type: "final"
92+
always: [{ actions: [{ type: "sendBackNextMoves" }] }],
93+
type: "final",
9694
},
9795
},
9896
onDone: "Update",
@@ -151,7 +149,7 @@ export const dme = setup({
151149
onDone: [
152150
{
153151
target: "Select",
154-
guard: "latestSpeakerIsUsr"
152+
guard: "latestSpeakerIsUsr",
155153
},
156154
{ target: "Update" },
157155
],

src/isu.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ dmActor.subscribe((snapshot: AnyMachineSnapshot) => {
160160
"%cState value:",
161161
"background-color: #056dff",
162162
snapshot.value,
163-
snapshot.context.is,
163+
snapshot.context.is
164164
);
165165
});
166166

src/nlug.ts

Lines changed: 31 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,36 @@ interface NLUMapping {
77
type NLGMapping = [Move, string][];
88

99
const nluMapping: NLUMapping = {
10-
"where is the lecture?": [{
11-
type: "ask",
12-
content: WHQ("booking_room"),
13-
}],
14-
"what's your favorite food?": [{
15-
type: "ask",
16-
content: WHQ("favorite_food"),
17-
}],
18-
pizza: [{
19-
type: "answer",
20-
content: "pizza",
21-
}],
22-
"dialogue systems 2": [{
23-
type: "answer",
24-
content: "LT2319",
25-
}],
26-
"dialogue systems": [{
27-
type: "answer",
28-
content: "LT2319",
29-
}],
10+
"where is the lecture?": [
11+
{
12+
type: "ask",
13+
content: WHQ("booking_room"),
14+
},
15+
],
16+
"what's your favorite food?": [
17+
{
18+
type: "ask",
19+
content: WHQ("favorite_food"),
20+
},
21+
],
22+
pizza: [
23+
{
24+
type: "answer",
25+
content: "pizza",
26+
},
27+
],
28+
"dialogue systems 2": [
29+
{
30+
type: "answer",
31+
content: "LT2319",
32+
},
33+
],
34+
"dialogue systems": [
35+
{
36+
type: "answer",
37+
content: "LT2319",
38+
},
39+
],
3040
};
3141
const nlgMapping: NLGMapping = [
3242
[{ type: "ask", content: WHQ("booking_course") }, "Which course?"],
@@ -56,7 +66,7 @@ export function nlg(moves: Move[]): string {
5666
}
5767
throw new Error(`Failed to generate move ${JSON.stringify(move)}`);
5868
}
59-
const utterance = moves.map(generateMove).join(' ');
69+
const utterance = moves.map(generateMove).join(" ");
6070
console.log("generated utterance:", utterance);
6171
return utterance;
6272
}

src/rules.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { objectsEqual } from "./utils";
1010

1111
type Rules = {
1212
[index: string]: (
13-
context: TotalInformationState,
13+
context: TotalInformationState
1414
) => ((x: void) => InformationState) | undefined;
1515
};
1616

@@ -220,7 +220,7 @@ export const rules: Rules = {
220220
const question = action.content as Question;
221221
const propositionFromDB = is.database.consultDB(
222222
question,
223-
is.shared.com,
223+
is.shared.com
224224
);
225225
if (propositionFromDB) {
226226
return () => ({
@@ -264,13 +264,13 @@ export const rules: Rules = {
264264
if (is.private.plan[0] && is.private.plan[0].type === "raise") {
265265
newIS = {
266266
...is,
267-
next_moves: [ ...is.next_moves, { type: "ask", content: q } ],
267+
next_moves: [...is.next_moves, { type: "ask", content: q }],
268268
private: { ...is.private, plan: [...is.private.plan.slice(1)] },
269269
};
270270
} else {
271271
newIS = {
272272
...is,
273-
next_moves: [ ...is.next_moves, { type: "ask", content: q } ],
273+
next_moves: [...is.next_moves, { type: "ask", content: q }],
274274
};
275275
}
276276
return () => newIS;
@@ -314,7 +314,7 @@ export const rules: Rules = {
314314
const answerMove: Move = { type: "answer", content: bel };
315315
return () => ({
316316
...is,
317-
next_moves: [ ...is.next_moves, answerMove ]
317+
next_moves: [...is.next_moves, answerMove],
318318
});
319319
}
320320
}
@@ -326,7 +326,7 @@ export const rules: Rules = {
326326
if (is.private.agenda[0] && is.private.agenda[0].type === "greet") {
327327
return () => ({
328328
...is,
329-
next_moves: [ ...is.next_moves, is.private.agenda[0] as Move ]
329+
next_moves: [...is.next_moves, is.private.agenda[0] as Move],
330330
});
331331
}
332332
},

src/semantics.ts

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1-
import { ShortAnswer, Proposition, Question } from "./types";
1+
import { ShortAnswer, Proposition, Question, Domain } from "./types";
22

3-
export function relevant(domain: Domain, a: ShortAnswer | Proposition, q: Question): boolean {
3+
export function relevant(
4+
domain: Domain,
5+
a: ShortAnswer | Proposition,
6+
q: Question
7+
): boolean {
48
if (
59
typeof a === "string" &&
610
domain.predicates[q.predicate] === domain.individuals[a]
@@ -11,16 +15,20 @@ export function relevant(domain: Domain, a: ShortAnswer | Proposition, q: Questi
1115
return true;
1216
}
1317
return false;
14-
};
18+
}
1519

1620
export function resolves(a: ShortAnswer | Proposition, q: Question): boolean {
1721
if (typeof a === "object" && q.predicate === a.predicate) {
1822
return true;
1923
}
2024
return false;
21-
};
25+
}
2226

23-
export function combine(domain: Domain, q: Question, a: ShortAnswer | Proposition): Proposition {
27+
export function combine(
28+
domain: Domain,
29+
q: Question,
30+
a: ShortAnswer | Proposition
31+
): Proposition {
2432
if (
2533
typeof a === "string" &&
2634
domain.predicates[q.predicate] === domain.individuals[a]

src/types.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ export type Domain = {
88
individuals: Individuals; // Mapping from individual to sort
99
};
1010

11-
1211
export type PlanInfo = {
1312
type: "action" | "issue";
1413
content: null | Proposition | ShortAnswer | Question;
@@ -29,9 +28,7 @@ export type Question = WhQuestion;
2928
type WhQuestion = { type: "whq"; predicate: string };
3029

3130
interface OtherMove {
32-
type:
33-
| "greet"
34-
| "request";
31+
type: "greet" | "request";
3532
content: null | string;
3633
}
3734
interface AnswerMove {
@@ -53,7 +50,7 @@ export type Action = {
5350
| "findout"
5451
| "consultDB";
5552
content: null | Question;
56-
}
53+
};
5754

5855
type Speaker = "usr" | "sys";
5956

test/dme.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ describe("DME tests", () => {
2323
notify: assign(
2424
({ context }, params: { speaker: string; message: string }) => {
2525
return { dialogue: [...context.dialogue, params] };
26-
},
26+
}
2727
),
2828
},
2929
types: {} as {
@@ -59,7 +59,7 @@ describe("DME tests", () => {
5959
moves: nlu(event.value),
6060
},
6161
}),
62-
{ delay: 1000 },
62+
{ delay: 1000 }
6363
),
6464
],
6565
},
@@ -74,11 +74,11 @@ describe("DME tests", () => {
7474
moves: (event as NextMovesEvent).value,
7575
},
7676
}),
77-
{ delay: 1000 },
77+
{ delay: 1000 }
7878
),
7979
{
8080
type: "notify",
81-
params: ({ event }) => ({
81+
params: ({ event }: any) => ({
8282
speaker: "sys",
8383
message: nlg(event.value),
8484
}),
@@ -119,7 +119,7 @@ describe("DME tests", () => {
119119
(snapshot) => snapshot.context.dialogue.length === expectedSoFar.length,
120120
{
121121
timeout: 1000 /** allowed time to transition to the expected state */,
122-
},
122+
}
123123
);
124124
expect(snapshot.context.dialogue).toEqual(expectedSoFar);
125125
});

tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,6 @@
1818
"noUnusedLocals": true,
1919
"noFallthroughCasesInSwitch": true
2020
},
21-
"include": ["src"]
21+
"include": ["src"],
22+
"exclude": ["src/dipper"]
2223
}

0 commit comments

Comments
 (0)