Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

During hour to hour development, I just let Visual Studio tell me about the errors as they come up. On the rare occasions I don't already have the editor open before deploying, I have a shell script to kick off the right tsc invocation. Otherwise, bundling plus uploading to the server is just another shell script. Yes, a full type check from scratch is slow, but it doesn't come up that often.


To anyone who wants to do this:

Let's say you have a tsconfig.json. Create a tsconfig-test.json like this:

    {
        "compilerOptions": {
            "noEmit": true,
            "skipLibCheck": true
        },
        "extends": "./tsconfig.json",
        "include": ["./\*/*.ts", "./\*/*.d.ts"]
    }
Add a script to your package.json (I use "test-types")

    ...
        "scripts": {
            "test-types": "tsc --project ./tsconfig-test.json",
    ...

Then you can "yarn test-types" quickly. I use husky[1] to run that command as a git pre-commit hook. My team cannot commit Typescript errors. Additionally I have a strict tsconfig and a strict eslint config (with these plugins:sonarjs, @typescript-eslint, simple-import-sort) which prevents "any" types and bad typescript hygiene. Results in faster code reviews.

[1] https://www.npmjs.com/package/husky




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: