Skip to content

v0.7.3 throws "TypeError: e.charAt is not a function" / "a.startsWith is not a function" for most files via CLI (regression from v0.7.2) #456

Closed

Description

@inouetakuya

What version of prettier-plugin-tailwindcss are you using?

v0.7.3 (works correctly on v0.7.2 with the same setup)

What version of Tailwind CSS are you using?

v4.1.18

What version of Node.js are you using?

v24.11.1

What package manager are you using?

pnpm v10.33.0

What operating system are you using?

macOS (Darwin 25.3.0)

Reproduction URL

(Will add a minimal repro repo on request — happy to provide if needed)

Describe your issue

After upgrading prettier-plugin-tailwindcss from 0.7.2 → 0.7.3, running Prettier via the CLI (prettier --check .) fails for almost every file in the project with one of the following errors:

  • TypeError: e.charAt is not a function — for files routed through the TypeScript parser (.ts, .tsx, next.config.ts, etc.)
  • TypeError: a.startsWith is not a function — for files routed through the Babel parser (.mjs such as eslint.config.mjs, postcss.config.mjs)

Pinning back to 0.7.2 resolves the issue completely. No other changes were made.

Stack trace (representative)

[error] next.config.ts: TypeError: e.charAt is not a function
[error]     at X4 (.../prettier@3.6.2/.../prettier/plugins/typescript.mjs:20:586)
[error]     at Object.e3 [as parse] (.../prettier@3.6.2/.../prettier/plugins/typescript.mjs:20:1508)
[error]     at parser.parse (.../prettier-plugin-tailwindcss@0.7.3/.../prettier-plugin-tailwindcss/dist/index.mjs:303:41)
[error]     at async parse5 (.../prettier@3.6.2/.../prettier/index.mjs:16731:11)
[error]     at async coreFormat (.../prettier@3.6.2/.../prettier/index.mjs:17287:25)
[error] postcss.config.mjs: TypeError: a.startsWith is not a function
[error]     at Xr (.../prettier@3.6.2/.../prettier/plugins/babel.mjs:12:444)
[error]     at Ca (.../prettier@3.6.2/.../prettier/plugins/babel.mjs:15:2211)
[error]     at Object.parse (.../prettier@3.6.2/.../prettier/plugins/babel.mjs:15:2570)
[error]     at parser.parse (.../prettier-plugin-tailwindcss@0.7.3/.../prettier-plugin-tailwindcss/dist/index.mjs:303:41)

The trace consistently passes through dist/index.mjs:303, which corresponds to:

parser.parse = async (code, options) => {
    let ast = await (await load(options)).parse(code, options, options);
    ...
}

Notably, the wrapped call passes options as a third argument to the underlying parser. In Prettier 3 the parser API is parse(text, options); the extra positional argument may be confusing downstream typing in some plugin/parser combinations, though I have not confirmed this is the exact cause.

Configuration

.prettierrc (one of the affected packages):

{
  "semi": false,
  "singleQuote": true,
  "plugins": ["prettier-plugin-tailwindcss"],
  "tailwindStylesheet": "./src/app/globals.css"
}

Another package additionally chains prettier-plugin-astro:

{
  "semi": false,
  "singleQuote": true,
  "plugins": ["prettier-plugin-astro", "prettier-plugin-tailwindcss"],
  "tailwindStylesheet": "./src/styles/globals.css",
  "overrides": [
    { "files": "*.astro", "options": { "parser": "astro" } }
  ]
}

Both packages are affected.

Possibly related

I'm happy to put together a minimal reproduction repo if it would help.

Activity

  1. RobinMalfait commented on Apr 26, 2026

    @RobinMalfait
    Contributor

    Hey! Please provide a minimal reproduction so we can take a look.

  2. inouetakuya commented on Apr 27, 2026

    @inouetakuya
    Author

    Hi @RobinMalfait, thanks for the quick response! I've put together a minimal reproduction:

    https://github.com/inouetakuya/prettier-plugin-tailwindcss-v0.7.3-repro

    Reproduction steps

    pnpm install
    pnpm format:check

    What it shows

    With prettier-plugin-tailwindcss@0.7.3 (and prettier 3.6.2, tailwindcss 4.1.18), prettier --check . throws three distinct TypeErrors depending on which parser is used:

    File Parser Error
    next.config.ts typescript TypeError: e.charAt is not a function
    eslint.config.mjs babel TypeError: a.startsWith is not a function
    postcss.config.mjs babel TypeError: a.startsWith is not a function
    src/app/globals.css postcss TypeError: t.slice is not a function

    The PostCSS parser case (globals.css) was not in my original report — I noticed it while building this minimal repro, so the regression appears to affect a fourth parser as well.

    Pinning back to 0.7.2 makes all four errors disappear (only formatting warnings remain). All traces pass through prettier-plugin-tailwindcss/dist/index.mjs:303 (the wrapped parser.parse).

    Let me know if there's anything else that would be helpful.

  3. RobinMalfait commented on Apr 27, 2026

    @RobinMalfait
    Contributor

    Hey! If you bump prettier to the next minor release, then it should start working:

    pnpm install prettier@3.7
    

    Or pnpm install prettier@latest if you want to upgrade to the latest version, which is 3.8.3 at the time of writing this.

    I'll likely get another 0.7.x release out with the old version, and a new 0.8.x to handle the breaking change. But this should help already 👍

  4. inouetakuya commented on Apr 27, 2026

    @inouetakuya
    Author

    Thanks @RobinMalfait! Confirmed that bumping prettier resolves all four TypeErrors while keeping prettier-plugin-tailwindcss@0.7.3.

    Verified on the minimal repro repo:

    • prettier@3.7.4 — all four TypeErrors gone, only formatting warnings remain
    • prettier@3.8.3 — same result

    Verification commits: https://github.com/inouetakuya/prettier-plugin-tailwindcss-v0.7.3-repro/tree/verify/prettier-bump-workaround

    The repro README has also been updated with this workaround. Looking forward to the upcoming 0.7.x and 0.8.x releases — thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions