Repository: tailwindlabs/tailwindcss
File: packages/tailwindcss/src/css-functions.ts (TypeScript)

Code before:
}

function alpha(_designSystem: DesignSystem, value: string, alpha: string, ...rest: string[]) {
  if (!value || !alpha) {
    throw new Error(
      `--alpha(…) requires 2 arguments, e.g.: \`--alpha(${value || 'var(--my-color)'}, ${alpha || '50%'})\``,
    )
  }

  if (rest.length > 0) {
    throw new Error(
      `--alpha(…) only aaccepts 2 arguments, e.g.: \`--alpha(${value || 'var(--my-color)'}, ${alpha || '50%'})\``,
    )
  }

  return withAlpha(value, alpha)
}

function spacing(designSystem: DesignSystem, value: string, ...rest: string[]) {
  if (!value) {
    throw new Error(`--spacing(…) requires a single value, but received none.`)
  }

  if (rest.length > 0) {
    throw new Error(
      `--spacing(…) only accepts a single value, but received ${rest.length + 1} values.`,
    )
  }

  let multiplier = designSystem.theme.resolve(null, ['--spacing'])
  if (!multiplier) {
    throw new Error('--spacing(…) depends on the `--spacing` theme value, but it was not found.')
  }

  return `calc(${multiplier} * ${value})`
}

function theme(designSystem: DesignSystem, path: string, ...fallback: string[]) {
  path = eventuallyUnquote(path)

  let resolvedValue = designSystem.resolveThemeValue(path)

  if (!resolvedValue && fallback.length > 0) {
    return fallback.join(', ')
  }

  if (!resolvedValue) {
    throw new Error(
      `Could not resolve value for theme function: \`theme(${path})\`. Consider checking if the path is correct or provide a fallback value to silence this error.`,
    )
  }

Review comment (suggestion):
Again, is "argument" better than "value" here?

```suggestion
      `The --spacing(…) function only accepts a single argument, but received ${rest.length + 1}.`,
```

Code after:
}

function alpha(_designSystem: DesignSystem, value: string, alpha: string, ...rest: string[]) {
  if (!value || !alpha) {
    throw new Error(
      `The --alpha(…) function requires two arguments, e.g.: \`--alpha(${value || 'var(--my-color)'}, ${alpha || '50%'})\``,
    )
  }

  if (rest.length > 0) {
    throw new Error(
      `The --alpha(…) function only accepts two arguments, e.g.: \`--alpha(${value || 'var(--my-color)'}, ${alpha || '50%'})\``,
    )
  }

  return withAlpha(value, alpha)
}

function spacing(designSystem: DesignSystem, value: string, ...rest: string[]) {
  if (!value) {
    throw new Error(`The --spacing(…) function requires an argument, but received none.`)
  }

  if (rest.length > 0) {
    throw new Error(
      `The --spacing(…) function only accepts a single argument, but received ${rest.length + 1}.`,
    )
  }

  let multiplier = designSystem.theme.resolve(null, ['--spacing'])
  if (!multiplier) {
    throw new Error(
      'The --spacing(…) function requires that the `--spacing` theme variable exists, but it was not found.',
    )
  }

  return `calc(${multiplier} * ${value})`
}

function theme(designSystem: DesignSystem, path: string, ...fallback: string[]) {
  path = eventuallyUnquote(path)

  let resolvedValue = designSystem.resolveThemeValue(path)

  if (!resolvedValue && fallback.length > 0) {
    return fallback.join(', ')
  }

  if (!resolvedValue) {
    throw new Error(
      `Could not resolve value for theme function: \`theme(${path})\`. Consider checking if the path is correct or provide a fallback value to silence this error.`,