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

Some settings can't be used in TOML config files. #1703

Open
1 task done
alinnert opened this issue Jul 16, 2019 · 3 comments
Open
1 task done

Some settings can't be used in TOML config files. #1703

alinnert opened this issue Jul 16, 2019 · 3 comments
Labels
contribution welcome Contributions welcome good first issue Good for newcomers type: bug Something isn't working

Comments

@alinnert
Copy link

  • I confirm that this is an issue rather than a question.

Bug report

Steps to reproduce

Notate the following setting in TOML instead of JS:

module.exports = {
  head: [
    ['link', { rel: 'icon', href: '/logo.png' }]
  ]
}

Which in theory would be:

head = [
  ["link", { rel = "icon", href = "/logo.png" }]
]

What is expected?

What is actually happening?

The TOML extension of VS Code reports: "Cannot add value of type InlineTable to array of type String. Toml Parser" - which is correct. Arrays in TOML only support values of the same type. The array at head[0] contains a mix of String and InlineTable though, which is not supported.

one = [1, 2] # ok
two = ["a", "b"] # ok
three = [1, "a"] # error

Other relevant information

There's an issue on the TOML repository about mixed typed arrays. TL;DR is: Some programming languages don't support arrays with mixed values, so it's safer to not support that in TOML either. That makes TOML files easier to read in more languages.

To fully support TOML config files the config structure needs to be changed at some points. Removing TOML support would be a bummer though, because I like the format.

One alternative example for the head config (TOML):

[[head]]
tag = "link"
attributes = [
  ['rel', 'icon'],
  ['href', '/logo.png']
]

Which would be equivalent to this JS:

module.exports = {
  head: [
    { tag: 'link', attributes: [['rel', 'icon'], ['href', '/logo.png']] }
  ]
}
  • Output of npx vuepress info in my VuePress project:

I don't think that's relevant here.

@thunderbiscuit
Copy link

This is a problem for us as well.

@yujingaya
Copy link

Workaround for now:

[[head.0]]
0 = "link"
1 = { rel = "logo", href = "/logo.png" }

@kefranabg kefranabg added type: bug Something isn't working contribution welcome Contributions welcome good first issue Good for newcomers labels Dec 10, 2019
@alinnert
Copy link
Author

alinnert commented Apr 3, 2020

Good news: It looks like this won't be an issue anymore with TOML 1.0: toml-lang/toml#676

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contribution welcome Contributions welcome good first issue Good for newcomers type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants