Skip to content
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

@:jcustomwrite should be respected on abstracts. #93

Open
EliteMasterEric opened this issue Oct 30, 2023 · 2 comments
Open

@:jcustomwrite should be respected on abstracts. #93

EliteMasterEric opened this issue Oct 30, 2023 · 2 comments

Comments

@EliteMasterEric
Copy link
Contributor

Here is an example of what I am trying to do:

typedef TypeToWrite = {
  var values:Array<EntrypointItem>
};

// This custom writer should be respected but is IGNORED for this abstract
@:jcustomwrite(package.Writers.writeEntrypointItem)
abstract EntrypointItem(Either<String, EntrypointObject>) from Either<String, EntrypointObject> to Either<String, EntrypointObject> {}

I want the values to be written, and parsed, as either a String or an EntrypointObject (which is a typical typedef), detecting what type it is.

There's also the problem that, when implementing writeEntrypointItem, there's no easy way to tell the writer to "write this object" instead of returning a string; you can JSON stringify the value you want to return, but that breaks the indentation of the file.

@elnabo
Copy link
Owner

elnabo commented Nov 1, 2023

Hello,

The custom write/read meta are only supported on fields at the moment.

As for the writer, I guess we could try at some point to modify the returned value and add the current tab level to most lines.

@EliteMasterEric
Copy link
Contributor Author

As for the writer, I guess we could try at some point to modify the returned value and add the current tab level to most lines.

That would be nice, I'd make it an option the way excluding nulls is.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants