Skip to content

Commit

Permalink
Remove source file from extraction context
Browse files Browse the repository at this point in the history
  • Loading branch information
farskid committed Jan 12, 2024
1 parent 302bfcb commit c3cb238
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 15 deletions.
16 changes: 8 additions & 8 deletions new-packages/ts-project/__tests__/state.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -260,19 +260,19 @@ test('should raise error when state.initial property has invalid value', async (
[
{
"node": NodeObject {
"end": 69,
"end": 70,
"exclamationToken": undefined,
"flags": 0,
"initializer": NodeObject {
"end": 69,
"end": 70,
"flags": 0,
"jsDoc": undefined,
"kind": 210,
"localSymbol": undefined,
"modifierFlagsCache": 0,
"multiLine": false,
"parent": undefined,
"pos": 66,
"pos": 67,
"properties": [],
"symbol": undefined,
"transformFlags": 0,
Expand All @@ -283,7 +283,7 @@ test('should raise error when state.initial property has invalid value', async (
"modifierFlagsCache": 0,
"modifiers": undefined,
"name": IdentifierObject {
"end": 65,
"end": 66,
"escapedText": "initial",
"flags": 0,
"flowNode": undefined,
Expand Down Expand Up @@ -518,18 +518,18 @@ test('should raise error when state.type has invalid value', async () => {
[
{
"node": NodeObject {
"end": 67,
"end": 68,
"exclamationToken": undefined,
"flags": 0,
"initializer": NodeObject {
"end": 67,
"end": 68,
"flags": 0,
"kind": 9,
"localSymbol": undefined,
"modifierFlagsCache": 0,
"numericLiteralFlags": 0,
"parent": undefined,
"pos": 63,
"pos": 64,
"symbol": undefined,
"text": "123",
"transformFlags": 0,
Expand All @@ -540,7 +540,7 @@ test('should raise error when state.type has invalid value', async () => {
"modifierFlagsCache": 0,
"modifiers": undefined,
"name": IdentifierObject {
"end": 62,
"end": 63,
"escapedText": "type",
"flags": 0,
"flowNode": undefined,
Expand Down
10 changes: 4 additions & 6 deletions new-packages/ts-project/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,12 @@ function findCreateMachineCalls(
}

function extractMachineConfig(
ctx: ExtractionContext,
ts: typeof import('typescript'),
createMachineCall: CallExpression,
) {
const ctx: ExtractionContext = {
errors: [],
};
const rootState = createMachineCall.arguments[0];
return [
{
Expand All @@ -56,11 +58,7 @@ export function createProject(
return [];
}
return findCreateMachineCalls(ts, sourceFile).map((call) => {
const ctx: ExtractionContext = {
errors: [],
sourceFile,
};
return extractMachineConfig(ctx, ts, call);
return extractMachineConfig(ts, call);
});
},
};
Expand Down
1 change: 0 additions & 1 deletion new-packages/ts-project/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import type { SourceFile } from 'typescript';

export interface ExtractionContext {
errors: ExtractionError[];
sourceFile: SourceFile;
}

// TODO: add error location/span
Expand Down

0 comments on commit c3cb238

Please sign in to comment.