本文介绍了LightSwitch中的TypeScript Intellisense的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在LightSwitch HTML客户端应用程序中使用TypeScript(从来没有想过我会使用该词,大声笑-见下文),以帮助我为屏幕创建Javascript代码.我写了一个关于我正在使用的过程的简短博客文章(并发推文-@yannduran)(如果有兴趣的话).

I'm using TypeScript in my LightSwitch HTML Client apps (never thought I'd use that word, lol - see below), to help me create the Javascript code for my screens. I wrote ashort blog post on the process I'm using (& tweeted it - @yannduran), if anyone's interested.

请务必注意,* me *" apps "是在手机,平板电脑或Windows 8 Metro中运行的HTML5/Javascript应用,& " 应用"是Silverlight/WPF/WinForms/.NET LOB 应用程序.

Just be be clear, to *me* "apps" are HTML5/Javascript apps that run on a phone, or tablet, or in Windows 8 Metro, & "applications" are Silverlight/WPF/WinForms/.NETLOB applications.

TypeScript通常会添加更好的智能感知,将在设计/编译时检查对象类型/属性名称等.但是,只有在知道"消息的情况下,它才能执行此操作.有关您正在使用的对象类型.在LightSwitch通常生成的代码中,这些类型并不明显.

TypeScript would normally add better intellisense, & would check object types/property names etc at design/compile-time. But it can only do this if it "knows" about theobject types you're using. In the code that LightSwitch normally generates, these types are not evident.

我的问题是,我该怎么做才能进行类型检查和检查?对功能参数(例如" screen "," contentitem ")的智能感知,默认情况下类型为" any ",不提供类型检查.做 我需要在TypeScript文件中添加特定的脚本引用,或者只需要在函数定义中添加对象类型(在这种情况下,这些参数的实际对象类型)?

My question is, what can I do to get type checking & intellisense on function parameters like "screen", "contentitem", which are by default of type "any", which doesn't provide type checking. Do I need to add particular script references to my TypeScript files, or do I just need to add the object types in the function definitions (in which case, what are theactual object types for those parameters)?

现在,TypeScript并没有给我带来比我自己编写Java脚本要多得多的东西,尤其是考虑到添加TypeScript文件所涉及的手动过程,&我必须记得要多么谨慎地编辑 ts 文件和不会无意间直接编辑 js 文件(我已经做了几次,并且想知道我写的*知道*的代码在哪里消失了",直到我意识到自己要做什么为止).完毕).但我相信TypeScript 可能是在LightSwitch HTML客户端应用程序中编写Java脚本的主要恩赐,但我只是没有允许我充分利用它的对象类型.

Right now, TypeScript isn't really giving me a whole lot more than what I'd have if I just wrote the Javascript myself, especially considering the manual process involved in adding TypeScript files, & how careful I have to remember to be to edit thets file & not accidentally edit the js file directly (which I've done a few times, & wondered where code that I *knew* I had written had "disappeared", until I realised what I'd done). But I believe that TypeScript could be a major boon to writing Javascript in LightSwitch HTML Client apps, but I just don't have the object types that would permit me to take full advantage of it.

我希望看到LightSwitch实际上生成了 TypeScript ,而不是 JavaScript ,默认情况下仅显示 ts 文件.这 ts 文件也需要是依赖的"文件,在屏幕文件上,如现在 js 文件(&当然 js 文件可以依赖于 ts 文件).是的,我可以手动设置所有设置,但是如果LightSwitch默认执行此操作会不会很好? :-)

I'd love to see LightSwitch actually generate TypeScript, instead ofJavascript, with only the ts files visible by default. Thets files also need to be "dependent" on the screen file, as thejs files are now (& of course the js file could then be dependent on thets file). Yes, I can set all that up manually, but wouldn't it be nice if LightSwitch did this by default? :-)

据我所知,生成TypeScript没有任何不利之处,任何 TypeScript可以使用Javascript代码,但也可以向代码中添加类型.正如TypeScript先生本人所说,"以Javascript开头,以Javascript 结尾".

There's no downside to generating TypeScript as far as I can see, as anyJavascript code is able to be used by TypeScript, but it can also add types to the code. And as Mr TypeScript himself said, "it starts with Javascript and it ends with Javascript".

Yann Duran
    - Pro Visual Studio LightSwitch 2011
的共同作者    -的作者 LightSwitch Central博客

免费下载: LightSwitch的发光工具
(用于LightSwitch的Visual Studio生产效率扩展)
  如果某人的答复回答了您的问题,请单击 标记为答案
如果有人的回复有用,请单击 投票为有帮助  这样做可以帮助所有人更快地找到答案.

Yann Duran
     - Co-Author of Pro Visual Studio LightSwitch 2011
     - Author of the  LightSwitch Central Blog

FREE Download: Luminous Tools for LightSwitch
(a Visual Studio productivity extension for LightSwitch)
 
Click Mark as Answer, if someone's reply answers your question
Click  Vote as Helpful, if someone's reply is helpful
 
By doing this you'll help everyone find answers faster.

推荐答案

TypeScript要求定义文件(d.ts)提供IntelliSense支持.由于没有自动的方法可以从现有的JavaScript库生成这些定义文件,因此草根工作称为绝对键入已迅速提供它们.但是,LightSwitch尚未包含在该列表中.鉴于LightSwitch在自定义添加的JavaScript(例如方法)中使用IntelliSense的困难,在适应方面似乎面临的挑战有些困难 与TypeScript相同.

TypeScript requires definition files (d.ts) to provide IntelliSense support.  Since there is no automatic way to generate these definition files from existing JavaScript libraries, a grassroots effort calledDefinitely Typedhas sprung up to provide them.  LightSwitch is not yet included in that list, however.   Given LightSwitch's difficulty with IntelliSense in custom-added JavaScript (methods, for example), the challenges seem a bit more difficult in adapting the same to TypeScript.

我听说SoftLandingCanada的Johnny Larue可能正在开发利用TypeScript的扩展,也许您和他可以合作.无论如何,如果继续,您将在LightSwitch和TypeScript方面处于开发的最前沿. 尝试使用它进行开发.

I have heard that Johnny Larue at SoftLandingCanada may be working on an extension that leverages TypeScript, perhaps you and he can collaborate.  In any case, you'll be on the cutting-edge of development in both LightSwitch and TypeScript if you continue to try development with it.

祝你好运.


这篇关于LightSwitch中的TypeScript Intellisense的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-25 08:49