New User- Typescript or Javascript

What’s the best/recommended scripting language to use with Cocos; Typescript or Javascript?

What are the main differences? (I’m looking for the easiest/fastest to implement.) or does mixing them up have some benefit?

I noticed that with Javascript there are some discrepancies in tutorials; for example the following function declarations both can be used

eg:
onLoad () {},
//or
onLoad:function(){},

…and so sometimes it all seems like guesswork which one to use (different ways to write the same thing). Is typescript any more consistent?

Thanks

We are moving towards TypeScript over JavaScript.

2 Likes

Thanks. The only only problem here is that all tutorials seem to be in JS and when I try to use code from a Typescript tutorial site (https://www.typescriptlang.org/docs/handbook/basic-types.html) VSCode doesn’t like it .
For example, declaring an array like:

@property
myArray: number[] = [1, 2, 3];

…doesn’t seem to appear in the editor properties.

Try:

@property({ type: [cc.Integer] })
myArray: Array<number> = [1,2,3];

Wow, When will official docs include typescript snippets code as well?

Indeed they will. Getting updated for Creator 3

1 Like

The thing I find most daunting about Cocos (when moving from Unity) is that I can’t simply highlight a command in the IDE and hit F1 to see an example of how its used. Something like that would be amazing in C3.
At the moment it seems quite a bit of effort to have to find help the online api documents and that’s the thing that slows me (and probably a lot of beginners like me) down the most. Maybe Cocos would need its own integrated IDE for this though (which would be even cooler).

We used to have an IDE. It’s EOLd

EOLd??

It’s old?

That Eclipse extension? Thank god that is dead! Use VSCode is WAAAYYYY better.

@Grimmy use TS code, the autocomplete will work better, and for the F1 / online API documentation, I agree that things could be better, but is something you can live with

1 Like

EOL. End of life.

It was called Cocos Code. I still have versions if you really wanna try it but it’s not gonna work for anything productive.

Gotcha. No no, I don’t want that thanks. I’ll stick to VSCode :slight_smile: Cheers

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.