Comments (11)
Thanks for the report @chrisdrackett
when adding aliases (?) to a component
What are the aliases in the code snippet?
the rest of the JSX does not render correctly
Can you share a screenshot of what you see and describe what's incorrect?
inspecting it looks like the scope goes from:
Where in the code are you when you're logging the scopes?
Lastly, do things look ok with Tree-sitter disabled?
from language-typescript.
Here is a screenshot without the typescript alias(? hopefully I'm using the right term, I'm new to ts):
and then after I add the alias:
notice that most the coloring (other than red) is lost after the <Query<taskListItem, taskListItemVariables>
line.
I currently have tree-sitter disabled because the coloring on files with JSX is completely strange when I turn it on. (here is a screenshot of tree-sitter, I believe:)
from language-typescript.
@chrisdrackett It's easier for someone else to reproduce and debug if you provide text that can be copied. Images are good to see exactly what you're talking about though.
from language-typescript.
sure, I was asked for screenshots so that is what I provided. Here is the related text:
export const TaskListItem = ({ id, children }: taskListItemProps) => (
<Query<taskListItem, taskListItemVariables>
query={TASK_LIST_ITEM}
variables={{ id }}
>
{(queryProps) => {
const { loading, data } = queryProps
if (!loading && data && data.task) {
return (
<Mutations task={data.task}>
{(mutations) => {
return children({ ...queryProps, mutations })
}}
</Mutations>
)
} else {
return children({ ...queryProps, mutations: undefined })
}
}}
</Query>
)
from language-typescript.
@Aerijo also, this text was available in my original issue request :D am I missing something? I can provide more if needed!
from language-typescript.
@chrisdrackett Right, sorry. I only saw the provided images and had a knee jerk reaction.
from language-typescript.
Adding that extra text makes tree-sitter-typescript interprete the tag as a type assertion, and then it gets an error when it sees the {
of {(queryProps)
. It continues normally, but sees the closing tag as a binary comparison with a regex.
As far as I can tell, that syntax is illegal anyway
Specifically,
The as operator
Recall how to write a type assertion:
var foo = <foo>bar;
This asserts the variable bar to have the type foo. Since TypeScript also uses angle brackets for type assertions, combining it with JSXâs syntax would introduce certain parsing difficulties. As a result, TypeScript disallows angle bracket type assertions in .tsx files.
Does this example compile and run properly?
from language-typescript.
it does. I got this format from the Apollo Client examples here:
https://github.com/apollographql/react-apollo/blob/master/examples/typescript/src/Character.tsx
not saying those are correct as well, but not only does it compile but I get the correct auto-complete in my editor. I'll keep digging as I'm super new to typescript :)
from language-typescript.
I stumbled into the same problem today. The syntax is not illegal though, Generic JSX components were introduced in Typescript 2.9. I tried setting the grammar to source.ts, but then I lose emmet, not sure how to proceed.
from language-typescript.
Confirmed this issue with another maintainer - Tree-sitter doesn't parse this as JSX and is a https://github.com/tree-sitter/tree-sitter-typescript issue.
Updated the issue body with that link to the Apollo example code and the code from #34 (comment).
from language-typescript.
Hey @as-cii, I'm out of office next week and you have some context on this, so I assigned you. My PRs in tree-sitter/tree-sitter-typescript#68 and #37 should be good to go. I'm just waiting on a second review for the change to tree-sitter-typescript
, and I don't anticipate much change will be needed.
from language-typescript.
Related Issues (20)
- Failed to load a language-typescript package grammar HOT 1
- Flow files no longer have `source.js` scope, snippets broken HOT 2
- TypeScript `export =` syntax not highlighted with inline declarations HOT 5
- Multiline arguments types invalid highlight HOT 2
- It's broken. fIx it
- NoSubstitutionTemplateLiteral breaks coloring HOT 1
- Variables that start with capital letter marked as types
- Template literals
- Package snippets don't work HOT 6
- update TextMate grammar HOT 3
- syntax highlighting issues.
- No syntax highlighting at all HOT 6
- .ts files are not auto detected HOT 2
- Type generics for React components break syntax highlighting HOT 1
- Failed to load a language-typescript package grammar HOT 1
- Failed to load a language-typescript package grammar HOT 10
- Support for "abstract" keyword
- I didn't find the Automatic Indenting of JSX feature.
- Classes with generic mixins applied to base do not highlight correctly #1573 HOT 1
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 language-typescript.