Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VS: systax highlighting #2320

Open
brunolau opened this issue Nov 19, 2017 · 8 comments
Open

VS: systax highlighting #2320

brunolau opened this issue Nov 19, 2017 · 8 comments

Comments

@brunolau
Copy link

First of all, I know this is more suitable for stackoverflow, but I've seen similar questions unanswered (including my own from cca 2 years earlier)

What do I have to do in order to enable the syntax highlighting in Visual Studio 2017 working with Razor cshtml?

No matter how hard I tried the data-bind attribute gets no special highlighting making it difficult to work with larger templates

@hbroer
Copy link

hbroer commented Apr 13, 2018

after working a few weeks with knockout i would first say: don't use knockout in 2018. ^^ But for syntax highlighting in old projects there could be a option. I don't use VS but there should be a similar option to what exists in webstorm. There it is called "language injection" which allows you to prefix the xml attribute data-bind and params with window["dummy_var"] = { and suffix it with }.

But this will not fix the lack of code completion features and the impossibility to do great unit tests. ^^

@Sebazzz
Copy link
Contributor

Sebazzz commented Apr 14, 2018

I actually never got code highlighting to work in Visual Studio, not since 2015 at least. I suspect the feature has silently be removed, especially since they introduced the new Javascript language service based on the Typescript compiler. I think you will have to live with it.

after working a few weeks with knockout i would first say: don't use knockout in 2018.

Why? Because it is not as hot as React?

@hbroer
Copy link

hbroer commented Apr 17, 2018

because "the lack of code completion features and the impossibility to do great unit tests." The Template System breaks everything. And yes, after using JSX for a few month i am sure that it is the much better solution than html with additional tags which do magic mystic meat in the background. ^^ And there are a few Features which are totally missing like SSR, HMR.

i don't understand why so many people with M$ .net background think this framework is a good solution in 2018. I didn't see a single feature which makes knockout a must have. ^^

But who cares. just sayn' ^^

@chrisknoll
Copy link

The lack of code completely features is something that should be better, tho I haven't run into that problem since I don't use that editor. But the premise that JSX enables unit testing that would be otherwise "impossiblity to do great unit tests", I think you're suffering from JSX fanboi-ism if you think JSX is the only way to do 'great unit testing'. In think this repo and the TKO repo have done an amazing job with managing their test cases.

I'm surprised that you don't see observables and dependency tracking as one of the great features of knockout. And also how it is so easily modified by external plugins: the codebase hasn't needed major updates because it was built to last, yet new capabilities are developed out of the community every day because of how extensible it is. I'm sorry to feed the troll here (and even after hijacking the thread) but to say there's not a single feature in knockout that makes it a 'must have' is simply disingenuous.

@Sebazzz
Copy link
Contributor

Sebazzz commented Apr 17, 2018

the lack of code completion features

That is unfortunate, but not the fault of Knockout. Possible workaround include declaration of bindings in source code. But since you suggest you use plain Javascript, I don't think you care too much about good code completion anyway.

I can imagine that a JSX like binding for view models is also not impossible to develop, which would offer code completion more easily.

the impossibility to do great unit tests
I'd argue that you can unit tests ko.js projects better because you can separate the view from the view model and test the view model individually as a collection simple input/output properties.

And there are a few Features which are totally missing like SSR, HMR

HMR is trivial to built into a knockout SPA, check one of my projects as an example. SSR is being worked on for tko IIRC.

html with additional tags attributes which do magic mystic meat in the background

Well, isn't JSX complete non-HTML tags which do a lot of magic in the background?

@hbroer
Copy link

hbroer commented Apr 18, 2018

i try to for a short time and found that not to be a ez task to do. And if we did, the effort to refactor the whole project would be same as to switch to the react ecosystem.

well, JSX is Javascript. Instead of transforming HTML to Javascript and then rendered back to HTML, or to manipulate the DOM tree with jquery, JSX only needs to be rendered (not 100% true, but mostly). I like how i can play with JSX Objects inside of unit tests.

I will take a look at your sources for HMR. Thanks for the hint :)

@vfle
Copy link

vfle commented Aug 17, 2018

Any updates for VS 2017 razor highlight & intellisense?

From what i understand, vs 2017 changes the way intellinse works from the
/// style to using typescript definitions from what i read here.

@xairrick
Copy link

xairrick commented Mar 7, 2019

It seems like when you enable the new JavaScript language services in vs 2017, it disables the the intellisense on the data-bind attributes in html files. You have to restart VS for changes to take effect.

HOWEVER: on two different machines, when I disabled the new javascript language service, the html editor would throw and error when I tried to edit a data-bind attribute.

As alternative you might be able to use VS Code for knockout intellisense https://stackoverflow.com/questions/41636473/html-knockoutjs-intellisense-in-visual-studio-code

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

No branches or pull requests

6 participants