Code Monkey home page Code Monkey logo

Comments (3)

dpvc avatar dpvc commented on May 31, 2024

Thanks for the pointer. It looks like this turns on four things: noImplicitAny, noImplicitThis, alwaysStrict, and strictNullChecks. We already have noImplicitAny enabled, and I don't think noImplicitThis or alwaysStrict would cause us any problems. But I'm not certain about strictNullChecks. I understand the desire to be careful about this, but I suspect it would take some work to make that compile cleanly for us (we do currently use the fact that null is allowed for any type at the moment), if I read this correctly.

I'm curious how this is supposed to be handled. Do you have to use a lot of type | null expressions when dealing with things that could be null (e.g., option lists, or child pointers, and so on)? or is there some better way to manage that?

from mathjax-src.

jasongrout avatar jasongrout commented on May 31, 2024

I think so - I don't have a ton of experience with it yet. If you already have type aliases set up, you can add | null. After you check for null, Typescript can infer the type is not null, or you can explicitly declare it so with the ! suffix to the type (e.g., string! declares a string | null as nonnullable).

See also "Nullable types" in https://www.typescriptlang.org/docs/handbook/advanced-types.html

from mathjax-src.

jasongrout avatar jasongrout commented on May 31, 2024

The strict null checking probably does take the most work to satisfy. We haven't turned it on for some of our codebases yet either.

from mathjax-src.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.