magicast icon indicating copy to clipboard operation
magicast copied to clipboard

[WIP] support $comment

Open fengkx opened this issue 1 year ago โ€ข 2 comments

๐Ÿ”— Linked issue

#21

โ“ Type of change

  • [ ] ๐Ÿ“– Documentation (updates to the documentation, readme, or JSdoc annotations)
  • [ ] ๐Ÿž Bug fix (a non-breaking change that fixes an issue)
  • [ ] ๐Ÿ‘Œ Enhancement (improving an existing functionality like performance)
  • [x] โœจ New feature (a non-breaking change that adds functionality)
  • [ ] ๐Ÿงน Chore (updates to the build process or auxiliary tools and libraries)
  • [ ] โš ๏ธ Breaking change (fix or feature that would cause existing functionality to change)

๐Ÿ“š Description

I've tried to implement part of the functionality and turning on the WIP Pull Request first. Would like to have comments and suggestions for this API design.

Here are some choices I have made.

  1. mod.exports.default.a.$comment = 'asdsad' // throw Error because mod.exports.default.a is proxied to a string , So I make $comment on every object for now. Take a look at the test cases for exampes.
  2. Always use leadding comment block instead of comment line
  3. If it has multipe comment on one node, getter will join them with newline('\n')

Question

How to deal with array field for example:

export defaut {
	urls: [
		/* comment about first url */
		"http://example.com",
		/* comment about second url */
		"http://example2.com"
	]
}

๐Ÿ“ Checklist

  • [x] I have linked an issue or discussion.
  • [ ] I have updated the documentation accordingly.

fengkx avatar Feb 23 '24 12:02 fengkx

@antfu Would you take a look on the API?

fengkx avatar Feb 23 '24 12:02 fengkx

I'm in a big need of this, this would be awesome!

Hugos68 avatar Jan 11 '25 21:01 Hugos68