Comments (8)
Yes, although applying any linting whatsoever to generated files is probably not a great idea. When we release the CLI, we'll even be able to gitignore these assets and generate them on CI.
This is a cheap enough change to make, though.
from xstate-tools.
@mattpocock we can probably just output never
at those locations instead of {}
- but it's best to double-check that and add those to all existing type gen tests in this repo. Maybe we could even just skip those keys if they are empty~? That could be even better as we'd save some parsing time.
from xstate-tools.
I'm currently working around this with an override in my eslint.json to disable that rule for *.typegen.ts
from xstate-tools.
@horacioh Yes, see the CLI docs:
https://xstate.js.org/docs/packages/xstate-cli/#xstate-cli
from xstate-tools.
So what is the recommended way to handle this ? Add typegen files to eslintignore ?
Yes, this is a reasonable approach.
I will probably look in the future for alternative approaches for this but the mentioned ESLint rule shouldn't always be blindly trusted anyway. There are some cases for which {}
is a better choice than all of the alternatives mentioned in this warning. So I'm not quite treating this as a high-priority issue.
from xstate-tools.
When we release the CLI, we'll even be able to gitignore these assets and generate them on CI.
@mattpocock Is there any example on how to do this on GH Actions? thanks in advance!
from xstate-tools.
YES!! I saw it and forgot to mention it here ;)
from xstate-tools.
HI all !
I'm having the same issue - toying around with a pretty simple machine that typegens this:
export interface Typegen0 {
"@@xstate/typegen": true;
internalEvents: {
"xstate.init": { type: "xstate.init" };
"xstate.stop": { type: "xstate.stop" };
};
invokeSrcNameMap: {};
missingImplementations: {
actions: never;
delays: never;
guards: never;
services: never;
};
eventsCausingActions: {
logEntry: "PLAY" | "STOP";
logExit: "PAUSE" | "STOP" | "xstate.stop";
logPaused: "PAUSE";
};
eventsCausingDelays: {};
eventsCausingGuards: {};
eventsCausingServices: {};
matchesStates: "paused" | "playing" | "stopped";
tags: never;
}
And the warnings as similar to what is described above
Don't use {} as a type. {} actually means "any non-nullish value".
- If you want a type meaning "any object", you probably want 'object' instead.
- If you want a type meaning "any value", you probably want 'unknown' instead.
- If you want a type meaning "empty object", you probably want 'Record<string, never>' instead.
eslint(@typescript-eslint/ban-types)
So what is the recommended way to handle this ? Add typegen files to eslintignore ?
Thanks
from xstate-tools.
Related Issues (20)
- [Feature Request] Add mermaid export to VSCode Extension HOT 1
- [Bug] VScode extension does not work if the machine is a property in a class HOT 5
- XState to md – how to generate documentation from xstate? HOT 1
- Bug: VSCode plugin error "<action> is never used in the machine definition" HOT 3
- xstate-cli typegen doesn't respect file casing after rename.
- Bug: typegen causes type error when a `service` is a function returning a StateMachine which has Context
- XState VSCode extension - Visual Editor shows unexpected errors when using multiple guarded transitions HOT 1
- @xstate/cli typegen regression from 0.5.2 HOT 2
- "Learn more" link button in vscode popup 404s HOT 1
- Running typegen command on machine with two invokes with one onDone fails
- (Feature Request) Use existing layout engine for autolayout HOT 1
- vs-code extension delete machine when defined as a createMachine parameter
- export to scxml file HOT 4
- VSCode Editor shows error on transitions when using "guard" (V5) instead "cond" (v4) HOT 2
- Bug: Typescript 'something is never used in the machine definition' when it is used HOT 2
- XState VSCode extension shows `__@@INLINE_IMPLEMENTATION@@__` string for all `onDone, onError` handlers in visualization
- Build instructions for vscode extension?
- Editor fails to save the changes on windows HOT 2
- "Jump to definition" doesn't work with v5's `setup(...)` API HOT 3
- Bug: VSCode visualizer doesn't resolve imported variables HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from xstate-tools.