News for hackers. Stuff that matters.
Re:TypeScript at Google by eksemplar on Sunday September 02, 2018 @01:27AM (#17895715)
How?

I think it’s inferior because it allows you to rewrite only parts, and unless you convert your entire code base, then you’ll not have type safety. Because the bits that aren’t typescript won’t warn you when you compile.

Re:TypeScript at Google by tonyhb on Sunday September 02, 2018 @02:00AM (#17895824)
> Because the bits that aren’t typescript won’t warn you when you compile.

You just wrote exactly why static types are great: you get warnings when you forget to refactor your shitty (sic) JS code.

Re:TypeScript at Google by nojvek on Sunday September 02, 2018 @01:56AM (#17895813)
Typescript will happily check your JavaScript code with “allowJs” compiler flag.

We write all our new code in good ol ES6 flavor of JavaScript and typehint in jsdoc. Typescript as a typechecker serves as very well.

It’s a great incremental adoption strategy.

Re:TypeScript at Google by sandGorgon on Sunday September 02, 2018 @06:42AM (#17896488)
can you explain how this works ? this is very interesting to us. We have a large react app (created using create-react-app) in ES6 and have been considering adopting TS gradually.

This seems a great first step.

Re:TypeScript at Google by 52-6F-62 on Sunday September 02, 2018 @11:27AM (#17897297)
AFAIU, just add typescript to your project or globally then in your project set a tsconfig.json file with the allowJs and esModuleInterop flags set to true. Don’t quote me on this but you can probably leave out most of the rest of the flags besides your source location. For example:

    {
        “compilerOptions”: {
            “allowJs”: true,
            “esModuleInterop”: true
        },
        “include”: [ “src/**/*” ],
        “exclude”: [ “node_modules/**/*” ]
    }
You’ll probably have to tweak that, but I hope it helps.

https://www.typescriptlang.org/docs/handbook/compiler-option...

Re:TypeScript at Google by nojvek on Sunday September 02, 2018 @11:28AM (#17897301)
See https://github.com/Microsoft/TypeScript/wiki/JSDoc-support-i...

Also Google’s puppeteer project is typechecked with tsc and the type info is all in jsdocs

https://github.com/GoogleChrome/puppeteer

Re:TypeScript at Google by realusername on Sunday September 02, 2018 @06:45AM (#17896497)
> I think it’s inferior because it allows you to rewrite only parts

That's exactly why it's superior, your project just becomes better step by step without an expensive and complicated full rewrite.