question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Let us slowly move to Typescript. (instructions inside)

See original GitHub issue

I set up Typescript pretty easily with Cesium (with minimal friction).

  1. Install Typescript: npm install --save-dev typescript

  2. Create a file in the root directory tsconfig.json:

    {
        "compilerOptions": {
            "target": "es3",
            "module": "amd"
        },
        "include": [
            "./Source/**/*.ts"
        ]
    }
    
  3. Rename all js files in the pattern below (except the ones with “!”) to .ts (taken from gulpfile.js):

    ['Source/**/*.js',
    '!Source/*.js',
    '!Source/Workers/**',
    '!Source/ThirdParty/Workers/**',
    'Source/Workers/createTaskProcessorWorker.js'];
    

    I just went in the directories (not the “!” ones) and ran the recursive command:

    find . -name "*.js" -exec rename 's/\.js$/.ts/' '{}' \;
    
  4. Use the Typescript watcher to automatically compile Typescript to Javascript upon changes:

    tsc -w -p .
    
  5. The resulting Javascript files will be placed next to the ts files. This will let us keep our current build process and reap the benefits of Typescript with minimal effort. We can just use a .gitignore for the js files. gulp-typescript does exist (see link at bottom).

Remember that Typescript is a superset of Javascript. Therefore, all of our current code works completely fine. Now, we can incrementally migrate. With type-checking, compiler options like strictNullChecks, noImplicitAny, noImplicitReturns, and much more (see link below), a proper module system with import/export, we can create new features faster and find dormant bugs (with type checking). Also, less tests! We don’t have many contributors… so Typescript would definitely help. And you can finally use a proper IDE with autocomplete and refactoring tools.

We can complicate the build process with gulp-typescript and more, but I want us to start with the bare minimum first so we don’t scare anyone away. Minimal friction is the keyword here.

Issue Analytics

  • State:open
  • Created 7 years ago
  • Reactions:7
  • Comments:11 (8 by maintainers)

github_iconTop GitHub Comments

3reactions
custompro12commented, Dec 5, 2019

Any update on this?

0reactions
mramatocommented, Jun 3, 2020

Whoops, thanks. It was supposed to say “now shipping” fixed 😄

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to slowly move to / migrate to TypeScript in an existing ...
What we tried: We use a pattern for organizing our JS code simillar to the MODULE TypeScript construct. We tried to rewrite a...
Read more >
How to move your project to TypeScript - at your own pace
Learn how you can move your existing JavaScript project, step by step to TypeScript. All at your own pace and as much as...
Read more >
Documentation - Migrating from JavaScript - TypeScript
Converting a JavaScript codebase over to TypeScript is, while somewhat tedious, usually not challenging. In this tutorial, we're going to look at how...
Read more >
10 Strategies for migrating to TypeScript - Exploring JS
We can support a mix of JavaScript and TypeScript files for our code base. We start with only JavaScript files and then switch...
Read more >
Gradual move to TypeScript. Running JavaScript and ...
Gradual Migration to TypeScript. And in order to keep those languages side-by side, we need to make sure that we can: Import TypeScript...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found