Ron McLeod

Saloon Keeper
+ Follow
since Feb 12, 2013
Ron likes ...
Android Angular Framework Eclipse IDE Java Linux MySQL Database Redhat TypeScript
Richmond, BC, Canada
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Rancher Scavenger Hunt
expand Ranch Hand Scavenger Hunt Green check
expand Greenhorn Scavenger Hunt

Recent posts by Ron McLeod

Carey Brown wrote:

Even with that change, I can't see how that line is going to work if A and b and numbers and the other variables are strings.  

For example:

Edit: I'm assuming that getField returns a String. - maybe that is a wrong assumption??
3 days ago
You're welcome

Bob Nedwor wrote:So "let" is a valid key word in ES2018?

Yup - it was included starting with ES6/ES2015.  There is a good explanation in this article: Variables and Constants in ES6.

The specification for ES2018 is detailed in ECMAScript® 2018 Language Specification

I would start by looking at LogCat to see what it shows.
3 days ago
--target specifies the version of JavaScript which should be generated by tsc.

If your TypeScript code only includes features which are also included on the version that you are transpiling to, then the generated JavaScript code will basically be identical to the original TypeScript code.  The big advantage in that case would be that if you included type declarations in your TypeScript code, the transpiler can verify these at compile/transpile time.

Bob Nedwor wrote:Thanks, everyone but I thought that the idea of tcs is to transpile TypeScript into Javascript. It works great without the --target option.
The default is ES3.

I think the point you are missing is that the transpiler is generating JavaScript code.  The language features that you are using in your TypeScript code are identical in ES2018, so other than removing blank lines and maybe comments, you will not see any difference.

In my last post I tried to show that when you use something in TypeScript where there is no translatable concept it may just get dropped.  Other features like TypeScript enums for example, will get polyfilled with something functionally equivalent.  For example:

The Mozilla Developer Network site has good explanations of CORS and Same-origin policy.
4 days ago
If you use TypeScript features which don't translate to JavaScript features , then you will see a difference.  For example, a type alias:

It looks like your code is already valid ES2018 code ...

ES2015 (ES6), ES2018
ES3, ES5

Bob Nedwor wrote:Each time tsc seems to do nothing other than put the contents of the .ts file into the .js file

The language features that you are using with TypeScript may translate directly to ES2018.

Can you show us the contents of the .ts source file and the .js transpiled file?

paul nisset wrote:What has been the biggest mistake you've made when designing a Web API for one of your projects?

One of my biggest mistakes was to publish an API too early, get some traction, and later try to pull it back and convince the users to move to a newer API.  This is especially difficult when there is no apparent benefit for them.

In addition to hearing a reply for your more general question, I would be interesting in hearing from Arnaud how he has dealt specifically with revving an API (without upsetting the consumers of the services).
4 days ago
I'm not sure if you discuss this in your book, but I'm wondering what your thoughts are on implicit vs explicit type declarations.  I find myself wanting to explicitly declare the type/return-types for variables and functions when it is not necessary.

I have read opinions that the in general, the application programmers should focus on the application and not worry about types; that those concerns should be left to the compiler.  

With something like this, it is obvious that the type is boolean, and does not need to be explicitly declared
But when calling function where the name does not clearly indicate what it might return, I tend to want to explicitly state what I understand is it will return
Same with the function itself.  This is example is quite simple so it is obvious what type it returns, but with something some complex, I feel like I should declare the return type, even though it really required.

If you planning on digging in to the Angular framework, in addition to this book, I recommend you spend some time studying Typescript and Reactive programming in-advance so that you can focus on the Angular concepts and not get hung-up on the language or RxJS.

There are many excellent books and online video courses that cover both these areas.
I spotted your book on Manning a few weeks back and I've added it in my wishlist for when I'm done with others already in the reading pipeline.

Thanks for joining us on CodeRanch.