facebook / facebook/stylex

[babel-plugin] Provide better error messages

Open
#560 0 comments 5 reactions 0 assignees View on GitHub
enhancement
Dominant language
JavaScript
Stars
10.3k
Forks
481
Avg merge
3d 8h
Merged PRs (30d)
13

Description

### Describe the feature request

After using StyleX for some time, I think it would be great to have some more accurate error messages displaying details like error line and optionally part of the invalid code if that's possible?

Let's take this example:
```ts
// some-file.stylex.ts

// dynamic/incorrect value for stylex
let displayValue = "flex";

const styles = stylex.create({
base: {
display: displayValue
}
})
```

### Current formatting:

**Errror:** Users/...path.../some-file.stylex.ts Only static values are allowed inside of a stylex.create() call.

### New formatting:

**Errror:** Only static values are allowed inside of a stylex.create() call. Evaluating `display: displayValue` at Users/...path.../some-file.stylex.ts`:43`

With the new formatting:
- Important details are listed first - "What's wrong?" and "Which part?"
- Longer details which are harder to read are listed at the end showing path and broken line in the code

In my opinion it would make the debugging experience a bit easier and intuitive. 🙏🏻

The current appearance of errors makes me a bit concerned about the "lack of control" over the state of the codebase when I am not receiving enough details. 😅

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.