How to use domReady with TypeScript

classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

How to use domReady with TypeScript

dolot
Just starting to play around with TypeScript and dojo and having a problem right off.  I have the following TypeScript code:

class adminMockupTools {

    //code to do stuff.

}

require(["dojo/domReady!"], function () {
    //do some things after the dom loads
});

The problem that I'm having is that 'require' is not recognized by the TypeScript Compiler.  I'm guessing this has something to do with something being out of scope, but not sure how to fix it.

Any advice would be appreciated.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to use domReady with TypeScript

Simon Walter
On 06/04/2016 05:20 AM, dolot wrote:

> Just starting to play around with TypeScript and dojo and having a problem
> right off.  I have the following TypeScript code:
>
> class adminMockupTools {
>
>      //code to do stuff.
>
> }
>
> require(["dojo/domReady!"], function () {
>      //do some things after the dom loads
> });
>
> The problem that I'm having is that 'require' is not recognized by the
> TypeScript Compiler.  I'm guessing this has something to do with something
> being out of scope, but not sure how to fix it.
>
> Any advice would be appreciated.
>
>

I don't know how the TypeScript Complier works. Are you sure it was
designed to work with Dojo?

I think you might want to ask Microsoft, but what you are doing sounds
incorrect:
"TypeScript is designed for development of large applications and
transcompiles to JavaScript."

So you need to compile TypeScript with the TypeScript Compiler, which
turns it into Javascript. Where did you hear that you can compile
Javascript with the TypeScript Compiler?

Simon
--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to use domReady with TypeScript

MistaPink
Hi Simon,

Since TypeScript is a superscript of JavaScript it allows the usage of
JavaScript. This also stated right on https://www.typescriptlang.org/:
"Use existing JavaScript code,"[...]

In my opinion this is also a big let down, since it allows to work with
"errorneous" JS code and does not force one to use TypeScript
completely. But this is another discussion.

Cheers,
Paul

On 06/15/2016 08:05 AM, Simon Walter wrote:

> On 06/04/2016 05:20 AM, dolot wrote:
>> Just starting to play around with TypeScript and dojo and having a problem
>> right off.  I have the following TypeScript code:
>>
>> class adminMockupTools {
>>
>>       //code to do stuff.
>>
>> }
>>
>> require(["dojo/domReady!"], function () {
>>       //do some things after the dom loads
>> });
>>
>> The problem that I'm having is that 'require' is not recognized by the
>> TypeScript Compiler.  I'm guessing this has something to do with something
>> being out of scope, but not sure how to fix it.
>>
>> Any advice would be appreciated.
>>
>>
>
> I don't know how the TypeScript Complier works. Are you sure it was
> designed to work with Dojo?
>
> I think you might want to ask Microsoft, but what you are doing sounds
> incorrect:
> "TypeScript is designed for development of large applications and
> transcompiles to JavaScript."
>
> So you need to compile TypeScript with the TypeScript Compiler, which
> turns it into Javascript. Where did you hear that you can compile
> Javascript with the TypeScript Compiler?
>
> Simon
>
--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to use domReady with TypeScript

MistaPink
In reply to this post by dolot
Hi,

What is the specific error? Whenever we used JavaScript within
TypeScript (esp. for global variables) the compiler told us about it but
it compiled the code anyway.

You can try to use declare var at the top or whereever you like:
declare var require;

With that we got around the compile complaining about the missing variables.

Cheers,
Paul

On 06/03/2016 10:20 PM, dolot wrote:

> Just starting to play around with TypeScript and dojo and having a problem
> right off.  I have the following TypeScript code:
>
> class adminMockupTools {
>
>      //code to do stuff.
>
> }
>
> require(["dojo/domReady!"], function () {
>      //do some things after the dom loads
> });
>
> The problem that I'm having is that 'require' is not recognized by the
> TypeScript Compiler.  I'm guessing this has something to do with something
> being out of scope, but not sure how to fix it.
>
> Any advice would be appreciated.
>
>
>
> --
> View this message in context: http://dojo-toolkit.33424.n3.nabble.com/How-to-use-domReady-with-TypeScript-tp4006887.html
> Sent from the Dojo Toolkit mailing list archive at Nabble.com.
>
--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to use domReady with TypeScript

dolot
The error I was getting was a compile error - it wasn't recognizing 'require'.  I downloaded the DefinitelyTyped type definitions for dojo and subsequently imported the namespaces that I needed using the 'Import' statement, but there were problems there as well.  My project compile times went up by several fold and Visual Studio developed a huge memory leak.  Ultimately I gave up and went with a work around.  I define an interface to hold all the functionality I have that relates to dojo and then write a separate javascript function that matches the interface definition and just use that.  It's a little convoluted, but it works.

The more I get into TypeScript, the more it seems like an 'almost good' idea.  :)
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to use domReady with TypeScript

Simon Walter
In reply to this post by MistaPink
On 06/15/2016 05:47 PM, [hidden email] wrote:
> Hi Simon,
>
> Since TypeScript is a superscript of JavaScript it allows the usage of
> JavaScript. This also stated right on https://www.typescriptlang.org/:
> "Use existing JavaScript code,"[...]
>

I suppose it would be better to design the application is such a way
that the Javascript code that results from compiling Typescript calls
the Javascript libraries such as Dojo, rather than compiling Dojo code
with Typescript. I am pretty sure complications will arise.

This will take some forethought, but it doesn't seem impossible - just
nasty. Why even deal with MS's EEE?

That's just my opinion though.

Cheers,

Simon

--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to use domReady with TypeScript

Simon Walter
In reply to this post by dolot


On 06/15/2016 10:55 PM, dolot wrote:
> The error I was getting was a compile error - it wasn't recognizing
> 'require'.  I downloaded the DefinitelyTyped type definitions for dojo and
> subsequently imported the namespaces that I needed using the 'Import'
> statement, but there were problems there as well.  My project compile times
> went up by several fold and Visual Studio developed a huge memory leak.
> Ultimately I gave up and went with a work around.  I define an interface to
> hold all the functionality I have that relates to dojo and then write a
> separate javascript function that matches the interface definition and just
> use that.  It's a little convoluted, but it works.

Well, you beat me to it.

> The more I get into TypeScript, the more it seems like an 'almost good'
> idea.  :)
>

LOL!

--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to use domReady with TypeScript

dylanks
fwiw, the Definitely Typed definitions for Dojo are fairly out of date.
We created https://github.com/dojo/typings to provide a better starting
point.

For Dojo 2, the changes in TS 1.8, 2.0, and 2.1 are very useful in
getting TS to the point where it's really viable from the perspective of
a toolkit author, in terms of having things that will work well without
a number of kludges. It's taken a while to find and resolve various pain
points, but it's progressed a lot.

Regards,
-Dylan

on 6/18/16, 22:44 (GMT-07:00) Simon Walter said the following:

>
> On 06/15/2016 10:55 PM, dolot wrote:
>> The error I was getting was a compile error - it wasn't recognizing
>> 'require'.  I downloaded the DefinitelyTyped type definitions for dojo and
>> subsequently imported the namespaces that I needed using the 'Import'
>> statement, but there were problems there as well.  My project compile times
>> went up by several fold and Visual Studio developed a huge memory leak.
>> Ultimately I gave up and went with a work around.  I define an interface to
>> hold all the functionality I have that relates to dojo and then write a
>> separate javascript function that matches the interface definition and just
>> use that.  It's a little convoluted, but it works.
>
> Well, you beat me to it.
>
>> The more I get into TypeScript, the more it seems like an 'almost good'
>> idea.  :)
>>
>
> LOL!
>
--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest
Co-Founder, Dojo Toolkit
CEO, SitePen, Inc.  http://www.sitepen.com/
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: How to use domReady with TypeScript

dolot

I may give those new typings a spin – I’m sort of prototyping things right now – just experimenting to see if TypeScript will be something we want to integrate. 

 

Good to know about Dojo 2 – I wonder how the new changes will affect the ESRI library we use?

 

Have a great day!

Dave Southern

 

From: dylanks [via Dojo Toolkit] [mailto:[hidden email]]
Sent: Sunday, June 19, 2016 12:55 AM
To: dolot
Subject: Re: How to use domReady with TypeScript

 

fwiw, the Definitely Typed definitions for Dojo are fairly out of date.
We created https://github.com/dojo/typings to provide a better starting
point.

For Dojo 2, the changes in TS 1.8, 2.0, and 2.1 are very useful in
getting TS to the point where it's really viable from the perspective of
a toolkit author, in terms of having things that will work well without
a number of kludges. It's taken a while to find and resolve various pain
points, but it's progressed a lot.

Regards,
-Dylan

on 6/18/16, 22:44 (GMT-07:00) Simon Walter said the following:


>
> On 06/15/2016 10:55 PM, dolot wrote:
>> The error I was getting was a compile error - it wasn't recognizing
>> 'require'.  I downloaded the DefinitelyTyped type definitions for dojo and
>> subsequently imported the namespaces that I needed using the 'Import'
>> statement, but there were problems there as well.  My project compile times
>> went up by several fold and Visual Studio developed a huge memory leak.
>> Ultimately I gave up and went with a work around.  I define an interface to
>> hold all the functionality I have that relates to dojo and then write a
>> separate javascript function that matches the interface definition and just
>> use that.  It's a little convoluted, but it works.
>
> Well, you beat me to it.
>
>> The more I get into TypeScript, the more it seems like an 'almost good'
>> idea.  :)
>>
>
> LOL!
>

--

Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest

Co-Founder, Dojo Toolkit
CEO, SitePen, Inc.  http://www.sitepen.com/

 


If you reply to this email, your message will be added to the discussion below:

http://dojo-toolkit.33424.n3.nabble.com/How-to-use-domReady-with-TypeScript-tp4006887p4006927.html

To unsubscribe from How to use domReady with TypeScript, click here.
NAML

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to use domReady with TypeScript

dylanks
Esri is tracking our work and Dojo 2, and also making use of our typings
for using TS with Dojo 1.x.

Also, a few very small portions of Dojo 2 are allegedly in Esri ArcGIS
version 4...

That said, they usually trail Dojo by 6-24 months depending on how large
the changes we make are (and in the case of Dojo 2, it's the biggest
round of changes since 2007).

Regards,
-Dylan

on 6/20/16, 08:06 (GMT-07:00) dolot said the following:

> I may give those new typings a spin – I’m sort of prototyping things
> right now – just experimenting to see if TypeScript will be something we
> want to integrate.
>
>  
>
> Good to know about Dojo 2 – I wonder how the new changes will affect the
> ESRI library we use?
>
>  
>
> Have a great day!
>
> Dave Southern
>
>  
>
> *From:*dylanks [via Dojo Toolkit] [mailto:[hidden email]
> </user/SendEmail.jtp?type=node&node=4006928&i=0>]
> *Sent:* Sunday, June 19, 2016 12:55 AM
> *To:* dolot
> *Subject:* Re: How to use domReady with TypeScript
>
>  
>
> fwiw, the Definitely Typed definitions for Dojo are fairly out of date.
> We created https://github.com/dojo/typings to provide a better starting
> point.
>
> For Dojo 2, the changes in TS 1.8, 2.0, and 2.1 are very useful in
> getting TS to the point where it's really viable from the perspective of
> a toolkit author, in terms of having things that will work well without
> a number of kludges. It's taken a while to find and resolve various pain
> points, but it's progressed a lot.
>
> Regards,
> -Dylan
>
> on 6/18/16, 22:44 (GMT-07:00) Simon Walter said the following:
>
>
>>
>> On 06/15/2016 10:55 PM, dolot wrote:
>>> The error I was getting was a compile error - it wasn't recognizing
>>> 'require'.  I downloaded the DefinitelyTyped type definitions for
> dojo and
>>> subsequently imported the namespaces that I needed using the 'Import'
>>> statement, but there were problems there as well.  My project compile
> times
>>> went up by several fold and Visual Studio developed a huge memory leak.
>>> Ultimately I gave up and went with a work around.  I define an
> interface to
>>> hold all the functionality I have that relates to dojo and then write a
>>> separate javascript function that matches the interface definition
> and just
>>> use that.  It's a little convoluted, but it works.
>>
>> Well, you beat me to it.
>>
>>> The more I get into TypeScript, the more it seems like an 'almost good'
>>> idea.  :)
>>>
>>
>> LOL!
>>
>
> --
>
> Dojo Toolkit: http://dojotoolkit.org/
> Tutorials: http://dojotoolkit.org/documentation/
>
> [hidden email] </user/SendEmail.jtp?type=node&node=4006927&i=0>
> To unsubscribe, visit:
> http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest
>
> Co-Founder, Dojo Toolkit
> CEO, SitePen, Inc.  http://www.sitepen.com/
>
>  
>
> ------------------------------------------------------------------------
>
> *If you reply to this email, your message will be added to the
> discussion below:*
>
> http://dojo-toolkit.33424.n3.nabble.com/How-to-use-domReady-with-TypeScript-tp4006887p4006927.html
>
>
> To unsubscribe from How to use domReady with TypeScript, click here.
> NAML
> <http://dojo-toolkit.33424.n3.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>
>
>
> ------------------------------------------------------------------------
> View this message in context: RE: How to use domReady with TypeScript
> <http://dojo-toolkit.33424.n3.nabble.com/How-to-use-domReady-with-TypeScript-tp4006887p4006928.html>
> Sent from the Dojo Toolkit mailing list archive
> <http://dojo-toolkit.33424.n3.nabble.com/> at Nabble.com.
>
--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest
Co-Founder, Dojo Toolkit
CEO, SitePen, Inc.  http://www.sitepen.com/
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: How to use domReady with TypeScript

dolot

Thanks, Dylan – good info to know. I’ll pass it on to my dev lead.

 

Have a great day!

Dave Southern

 

From: dylanks [via Dojo Toolkit] [mailto:[hidden email]]
Sent: Monday, June 20, 2016 10:16 AM
To: dolot
Subject: Re: How to use domReady with TypeScript

 

Esri is tracking our work and Dojo 2, and also making use of our typings
for using TS with Dojo 1.x.

Also, a few very small portions of Dojo 2 are allegedly in Esri ArcGIS
version 4...

That said, they usually trail Dojo by 6-24 months depending on how large
the changes we make are (and in the case of Dojo 2, it's the biggest
round of changes since 2007).

Regards,
-Dylan

on 6/20/16, 08:06 (GMT-07:00) dolot said the following:


> I may give those new typings a spin – I’m sort of prototyping things
> right now – just experimenting to see if TypeScript will be something we
> want to integrate.
>
>  
>
> Good to know about Dojo 2 – I wonder how the new changes will affect the
> ESRI library we use?
>
>  
>
> Have a great day!
>
> Dave Southern
>
>  
>
> *From:*dylanks [via Dojo Toolkit] [mailto:[hidden email]
> </user/SendEmail.jtp?type=node&node=4006928&i=0>]
> *Sent:* Sunday, June 19, 2016 12:55 AM
> *To:* dolot
> *Subject:* Re: How to use domReady with TypeScript
>
>  
>
> fwiw, the Definitely Typed definitions for Dojo are fairly out of date.
> We created https://github.com/dojo/typings to provide a better starting
> point.
>
> For Dojo 2, the changes in TS 1.8, 2.0, and 2.1 are very useful in
> getting TS to the point where it's really viable from the perspective of
> a toolkit author, in terms of having things that will work well without
> a number of kludges. It's taken a while to find and resolve various pain
> points, but it's progressed a lot.
>
> Regards,
> -Dylan
>
> on 6/18/16, 22:44 (GMT-07:00) Simon Walter said the following:
>
>
>>
>> On 06/15/2016 10:55 PM, dolot wrote:
>>> The error I was getting was a compile error - it wasn't recognizing
>>> 'require'.  I downloaded the DefinitelyTyped type definitions for
> dojo and
>>> subsequently imported the namespaces that I needed using the 'Import'
>>> statement, but there were problems there as well.  My project compile
> times
>>> went up by several fold and Visual Studio developed a huge memory leak.
>>> Ultimately I gave up and went with a work around.  I define an
> interface to
>>> hold all the functionality I have that relates to dojo and then write a
>>> separate javascript function that matches the interface definition
> and just
>>> use that.  It's a little convoluted, but it works.
>>
>> Well, you beat me to it.
>>
>>> The more I get into TypeScript, the more it seems like an 'almost good'
>>> idea.  :)
>>>
>>
>> LOL!
>>
>
> --
>
> Dojo Toolkit: http://dojotoolkit.org/
> Tutorials: http://dojotoolkit.org/documentation/
>
> [hidden email] </user/SendEmail.jtp?type=node&node=4006927&i=0>
> To unsubscribe, visit:
> http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest
>
> Co-Founder, Dojo Toolkit
> CEO, SitePen, Inc.  http://www.sitepen.com/
>
>  
>
> ------------------------------------------------------------------------
>
> *If you reply to this email, your message will be added to the
> discussion below:*
>
> http://dojo-toolkit.33424.n3.nabble.com/How-to-use-domReady-with-TypeScript-tp4006887p4006927.html
>
>
> To unsubscribe from How to use domReady with TypeScript, click here.
> NAML
> <http://dojo-toolkit.33424.n3.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>
>
>
> ------------------------------------------------------------------------
> View this message in context: RE: How to use domReady with TypeScript
> <http://dojo-toolkit.33424.n3.nabble.com/How-to-use-domReady-with-TypeScript-tp4006887p4006928.html>
> Sent from the Dojo Toolkit mailing list archive
> <http://dojo-toolkit.33424.n3.nabble.com/> at Nabble.com.
>

--

Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest

Co-Founder, Dojo Toolkit
CEO, SitePen, Inc.  http://www.sitepen.com/

 


If you reply to this email, your message will be added to the discussion below:

http://dojo-toolkit.33424.n3.nabble.com/How-to-use-domReady-with-TypeScript-tp4006887p4006929.html

To unsubscribe from How to use domReady with TypeScript, click here.
NAML

Loading...