-
-
Notifications
You must be signed in to change notification settings - Fork 134
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
Task: Remove JS/TS decorators #3270
Comments
As discussed - this is a right step into the right direction - but even better would be functional components with hooks (and ts) ... which is quite impossible as this would equal an ui rewrite 2.0 ^^ since esbuild seems to work for now with these decorators we may leave them as is - it would only make the code a little better. a little more profit would be in cases where typescript is used for components as the decorators cannot be typed but the hoc function syntax works with typescript like: @neos-project/neos-ui-decorators.d.tsthis is not the same as in declare module "@neos-project/neos-ui-decorators" {
import {
InferableComponentEnhancerWithProps,
ConnectedProps,
} from "react-redux";
import { GlobalRegistry } from "@neos-project/neos-ts-interfaces";
export interface NeosContextInterface {
globalRegistry: GlobalRegistry;
configuration: {};
routes: {};
}
/**
* Infers the type of props that a neosifier will inject into a component.
* we reuse this behavior from {@link ConnectedProps}
*/
export type NeosifiedProps<TNeosifier> = ConnectedProps<TNeosifier>;
export const NeosContext: React.Context<NeosContextInterface | null>;
type MapRegistryToPropsParam<TStateProps> = (
globalRegistry: GlobalRegistry
) => TStateProps;
interface Neos {
<TStateProps = {}, TOwnProps = {}>(
mapRegistryToProps: MapRegistryToPropsParam<TStateProps>
): InferableComponentEnhancerWithProps<
TStateProps & { neos: NeosContextInterface },
TOwnProps
>;
}
export const neos: Neos;
} import { neos, NeosifiedProps } from "@neos-project/neos-ui-decorators"; // NeosifiedProps is basically ConnectedProps
import { connect, ConnectedProps } from "react-redux";
const neosifier = neos((globalRegistry) => ({
secondaryEditorsRegistry: globalRegistry
.get("inspector")
.get("secondaryEditors")
}));
const connector = connect(
(state) => ({
node: selectors.CR.Nodes.focusedSelector(state),
})
);
type NeosProps = NeosifiedProps<typeof neosifier>;
type StateProps = ConnectedProps<typeof connector>;
type OwnProps = {}
type Props = NeosProps & StateProps & OwnProps;
class YourComponent extends React.PureComponent<Props>
{
public render()
{
}
}
export default neosifier(connector(YourComponent)); Originally posted by @mhsdesign in #3207 (comment) |
hmm decorators might have a second chance https://www.heise.de/news/Programmiersprache-TypeScript-5-0-bringt-neues-Konzept-fuer-Decorators-7472681.html |
I think I would keep the decorators if they become a standard or reliable support in TS5. They help with structure IMO. |
Remove JS decorators because the rfc was rejected.
The text was updated successfully, but these errors were encountered: