Comments (2)
I've started taking a look at this, and after figuring out how to repro in fourslash, it looks like there is a crash coming from pretty deep within a call to ChangeTracker.getChanges
1) fourslash tests
tests/cases/fourslash/codeFixMissingTypeAnnotationOnExports47-tsx-with-dash.tsx
fourslash test codeFixMissingTypeAnnotationOnExports47-tsx-with-dash.tsx runs correctly:
Error: Debug Failure. False expression: Token end is child end
at processChildNode (src/services/formatting/formatting.ts:880:27)
at /Users/blickly/repos/TypeScript/src/services/formatting/formatting.ts:791:17
at visitNode (src/compiler/parser.ts:441:20)
at forEachChildInJsxAttribute (src/compiler/parser.ts:1022:16)
at forEachChild (src/compiler/parser.ts:1251:43)
at processNode (src/services/formatting/formatting.ts:788:9)
at processChildNode (src/services/formatting/formatting.ts:889:13)
at processChildNodes (src/services/formatting/formatting.ts:955:40)
at /Users/blickly/repos/TypeScript/src/services/formatting/formatting.ts:794:17
at visitNodes (src/compiler/parser.ts:447:20)
at forEachChildInJsxAttributes (src/compiler/parser.ts:1019:16)
at forEachChild (src/compiler/parser.ts:1251:43)
at processNode (src/services/formatting/formatting.ts:788:9)
at processChildNode (src/services/formatting/formatting.ts:889:13)
at /Users/blickly/repos/TypeScript/src/services/formatting/formatting.ts:791:17
at visitNode (src/compiler/parser.ts:441:20)
at forEachChildInJsxOpeningOrSelfClosingElement (src/compiler/parser.ts:1191:9)
at forEachChild (src/compiler/parser.ts:1251:43)
at processNode (src/services/formatting/formatting.ts:788:9)
at processChildNode (src/services/formatting/formatting.ts:889:13)
at /Users/blickly/repos/TypeScript/src/services/formatting/formatting.ts:791:17
at visitNode (src/compiler/parser.ts:441:20)
at forEachChildInParenthesizedExpression (src/compiler/parser.ts:756:16)
at forEachChild (src/compiler/parser.ts:1251:43)
at processNode (src/services/formatting/formatting.ts:788:9)
at processChildNode (src/services/formatting/formatting.ts:889:13)
at /Users/blickly/repos/TypeScript/src/services/formatting/formatting.ts:791:17
at visitNode (src/compiler/parser.ts:441:20)
at forEachChildInSatisfiesExpression (src/compiler/parser.ts:793:16)
at forEachChild (src/compiler/parser.ts:1251:43)
at processNode (src/services/formatting/formatting.ts:788:9)
at processChildNode (src/services/formatting/formatting.ts:889:13)
at /Users/blickly/repos/TypeScript/src/services/formatting/formatting.ts:791:17
at visitNode (src/compiler/parser.ts:441:20)
at forEachChildInAsExpression (src/compiler/parser.ts:786:16)
at forEachChild (src/compiler/parser.ts:1251:43)
at processNode (src/services/formatting/formatting.ts:788:9)
at formatSpanWorker (src/services/formatting/formatting.ts:521:9)
at /Users/blickly/repos/TypeScript/src/services/formatting/formatting.ts:440:9
at getFormattingScanner (src/services/formatting/formattingScanner.ts:69:17)
at Object.formatNodeGivenIndentation (src/services/formatting/formatting.ts:439:12)
at getFormattedTextOfNode (src/services/textChanges.ts:1342:36)
at format (src/services/textChanges.ts:1313:37)
at computeNewText (src/services/textChanges.ts:1316:15)
at /Users/blickly/repos/TypeScript/src/services/textChanges.ts:1278:33
at mapDefined (src/compiler/core.ts:518:28)
at /Users/blickly/repos/TypeScript/src/services/textChanges.ts:1273:33
at mapDefined (src/compiler/core.ts:518:28)
at Object.getTextChangesFromChanges (src/services/textChanges.ts:1263:16)
at _ChangeTracker.getChanges (src/services/textChanges.ts:1179:39)
at withContext (src/services/codefixes/fixMissingTypeAnnotationOnExports.ts:254:36)
After debugging a bit, I suspect the issue is that the formatter seems to rely on Node
s having a valid parent
pointer (such as here), which seem to be set to undefined
in the replacement node passed to the ChangeTracker
.
Is it safe to assume that the ChangeTracker
/ formatter in TS are designed to require valid parent
pointers?
from typescript.
Judging by the location, this looks more like that the formatter didn't consider -
to be a part of a name; it checks if it's a token (which I'm assuming is -
), then only complains if that's in JsxText, but surely it can be an attribute too.
from typescript.
Related Issues (20)
- Union argument type with and spread operator
- Reuse original type nodes even when part of the node is not usable
- ts.createSourceFile trims leading newlines, causing stored line numbers to mismatch HOT 4
- Narrowing by type predicate fails to produce intersection type with weak type
- at the class getter property,why is need it initialize, if not then report error code is ts(2739) HOT 2
- Bloomberg TS5.5-beta feedback HOT 1
- Conditional Type Inference Bug in TS 5.x
- Protected instance member inaccessible to same-class constructor via object destructuring assignment HOT 2
- [ERROR] 15:13:55 Error: Cannot set headers after they are sent to the client HOT 3
- Isolated declarations does not handle object getters and setters with different types HOT 5
- TypeScript does not support bigint literals in type literal keys HOT 1
- Isolated declarations uses type information when emitting computed object keys HOT 5
- Error: Debug Failure when importing `AssertionError` from `node:assert/strict` HOT 4
- transpileDeclaration - Errors on unresolvable globals HOT 2
- duplicate comments on decorated fields
- Type narrowing with union types create impossible case with else statement HOT 6
- Error when using `import()` type within JSDoc tag `@implements`
- Narrowring a readonly class with instanceof of does not work on the else branch HOT 1
- Disposables disposed of, even though they are passed to a wrapper and still in use HOT 3
- It's the JSON validator that complains here. HOT 3
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.