Comments (3)
I like the motivating example here, though it's definitely not the case that an object literal has a meaningfully-defined "start of line".
One implementation issue is that right now errors get an associated node which provides their error span, so we don't have any architectural way to do a span like
const foo = someFunc({
~~~~~~~~~~~~~~~~~~~~
where the span is a partial covering of part of the tree, nor do we have anything that is like "start at the start of the line" to help make the span not just be a single character that might be in the middle of some other punctuation soup. But I think that'd be fixable with some flags on the error object to say "highlighting the entire thing is not necessary".
Would be possibly open to PRs if we could have some better definition of what a better spanning rule is, showing the difficult cases as well as the easier ones. Super-long error spans aren't great but single-character spans can also be very hard to spot, so ensuring that we're getting a net benefit would be needed.
from typescript.
@RyanCavanaugh That's very helpful thanks for the additional input.
I was talking about this a bit with @Andarist as perhaps you inferred from the parallel #58061.
I had also suggested potentially just right padding the start of an object literal if the contents before the first newline were less than e.g. 4 chars. I realize there might be some nuance to "if the contents before the first newline...", so we'd need to determine the best way to represent something like that that integrates reasonably well with the current error span model. Depending on what these flags might enable, this might be more intuitive visually:
Although perhaps this would be much less straightforward since I assume VSCode's model for decoration assumes a correlation with existing characters. Just thought I'd throw it out there since IMO, given no restrictions, I think it is the most intuitive and makes the best use of visual space to convey the error location.
from typescript.
Yeah, there's currently no way to make an error squiggle appear in the virtual space beyond the end of a line. Error spans are just start/end.
from typescript.
Related Issues (20)
- JSDoc tags get lost when inheriting from a grandparent class
- Smarter String includes/endsWith/startsWith using template literal type predicates HOT 3
- Typed key accessor fails to infer type when used with generic HOT 2
- Upstream file not correctly recognized as output of other project when using path mappings HOT 9
- [nightly][regression] Wrong generic parameter inferred for constructed class instance HOT 1
- [nightly][regression] Some emitted imports are syntactically invalid HOT 5
- Array of numbers wrong sort HOT 9
- Mistake in README file
- Inconsistent Behavior with Equality Check Using `Pick<Readonly<T>, K>` in Mapped Type HOT 2
- Improve Omit field type check HOT 1
- Class parameter property with initializer before required property emits non-nullable parameter for declaration emit
- TypeScript emits incorrect type for setters in JSDoc
- Function returning `never` in branch doesn't narrow type if it's not explicitly annotated HOT 3
- Type Intersection incorrect for optional parameters in functions with `exactOptionalPropertyTypes: true`. `undefined` type is flip based off Intersection types
- Inconsistent tsc behavior on TS 5.4 HOT 3
- VSCode TypeScript extension writes tracing to the wrong directory on Mac OS HOT 1
- computed property name in an interface error when using `[]` already HOT 3
- Proposal: Type-side `instanceof` keyword and functionality HOT 8
- tsserver.js CPU/Memory Spike HOT 3
- Update README.md, CONTRIBUTING.md and SECURITY.md to reduce mistakes HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from typescript.