Skip to content

fix(@formatjs/ts-transformer): include source location in extraction warnings#6432

Merged
longlho merged 2 commits intomainfrom
longho/add-source-location-to-extraction-warnings
Apr 24, 2026
Merged

fix(@formatjs/ts-transformer): include source location in extraction warnings#6432
longlho merged 2 commits intomainfrom
longho/add-source-location-to-extraction-warnings

Conversation

@longlho
Copy link
Copy Markdown
Member

@longlho longlho commented Apr 24, 2026

Summary

  • Add file:line:col context to extraction error/warning messages in both the TypeScript transformer and Rust CLI extractor
  • TS side: handleError now accepts an optional AST node and uses ts.getLineAndCharacterOfPosition() to prepend location
  • Rust side: MessageExtractor stores source text and uses get_line_col() to format file:line:col in warnings/panics. Also emits eprintln! warnings when throws=false (previously silently skipped)

Before: [FormatJS] \id` must be a string literal to be extracted.**After:**src/components/Foo.tsx:12:5 [FormatJS] `id` must be a string literal to be extracted.`

Closes #6428

Test plan

  • bazel test //crates/formatjs_cli:formatjs_cli_test — 176 tests pass
  • bazel test //packages/ts-transformer:unit_test — all tests pass
  • bazel test //packages/cli/integration-tests:conformance_test — 60/60 conformance tests pass
  • All pre-commit hooks pass (oxfmt, rustfmt, gazelle, ast-grep, oxlint, commitlint)

🤖 Generated with Claude Code

longlho and others added 2 commits April 23, 2026 21:02
…warnings

Add file:line:col context to extraction error/warning messages in both the
TypeScript transformer and Rust CLI extractor. Closes #6428.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
… extraction errors

- Rust: test panic includes file:line:col for non-static id and defaultMessage (throws=true)
- Rust: test non-static defaultMessage is skipped without panic (throws=false)
- TS: test error includes file:line:col pattern (throws=true)
- TS: test onMsgError callback receives error with file:line:col (throws=false)

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@longlho longlho added this pull request to the merge queue Apr 24, 2026
Merged via the queue into main with commit 9e55a25 Apr 24, 2026
3 checks passed
@longlho longlho deleted the longho/add-source-location-to-extraction-warnings branch April 24, 2026 01:18
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.

Feature Request - add option to formatjs CLI that includes contextual information for warning/errors

1 participant