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

pass interface and field name to Symbol ctor to be used as description #1

Merged
merged 2 commits into from
May 21, 2017

Conversation

michaelficarra
Copy link
Collaborator

No description provided.

src/index.js Outdated
@@ -16,7 +16,7 @@ export syntax interface = ctx => {
let items = matchInterfaceItems(inner);
let fields = items.reduce((acc, item) => {
if (item.type === 'field' || item.type === 'static') {
return acc.concat(#`${item.name}: { value: Symbol(),
return acc.concat(#`${item.name}: { value: Symbol(${JSON.stringify(`${name}.${item.name}`)}),
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call but Sweet's API is a bit low level right now and won't auto-cast a string value to a string literal token. You need to do:

Symbol(${fromStringLiteral(item.name, unwrap(name).value + '.' + unwrap(item.name).value)})

(I'd normally use a template literal there but there's a bug I just discovered sweet-js/sweet-core#710 with function calls in template literals that I'm very surprised we hadn't run into before)

@michaelficarra
Copy link
Collaborator Author

@disnet Fixed.

@disnet disnet merged commit b46fceb into disnet:master May 21, 2017
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

Successfully merging this pull request may close these issues.

2 participants