-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
check action objects for implementation use #395
check action objects for implementation use #395
Conversation
🦋 Changeset detectedLatest commit: 1816004 The changes in this PR will be included in the next version bump. This PR includes changesets to release 0 packagesWhen changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
@@ -9,7 +9,7 @@ export const getUnusedActionImplementations: DiagnosticGetter = ( | |||
machineResult, | |||
) => { | |||
const allActions = getSetOfNames( | |||
machineResult.getAllActions(['named']) || [], | |||
machineResult.getAllActions(['named', 'object']) || [], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The 'object'
declaration type doesn't exist:
xstate-tools/packages/machine-extractor/src/MachineExtractResult.ts
Lines 603 to 608 in d9cc11d
declarationTypes: DeclarationType[] = [ | |
'identifier', | |
'inline', | |
'unknown', | |
'named', | |
], |
was this maybe intended as a draft PR? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does exist, that default array is just confusing
xstate-tools/packages/machine-extractor/src/types.ts
Lines 87 to 92 in d9cc11d
export type DeclarationType = | |
| 'named' | |
| 'inline' | |
| 'identifier' | |
| 'object' | |
| 'unknown'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Used over here
xstate-tools/packages/machine-extractor/src/actions.ts
Lines 121 to 142 in d9cc11d
export const ActionAsObjectExpression = createParser({ | |
babelMatcher: t.isObjectExpression, | |
parseNode: (node, context): ActionNode => { | |
const id = context.getNodeHash(node); | |
for (const prop of node.properties) { | |
if (t.isObjectProperty(prop)) { | |
if ( | |
getObjectPropertyKey(prop) === 'type' && | |
t.isStringLiteral(prop.value) && | |
!SUPPORTED_BUILTIN_ACTIONS.includes(prop.value.value) | |
) { | |
return { | |
action: id, | |
node, | |
name: prop.value.value, | |
kind: 'named', | |
declarationType: 'object', | |
inlineDeclarationId: id, | |
}; | |
} | |
} | |
} |
Resolves #355
Resolves #373