GithubHelp home page GithubHelp logo

Comments (5)

yungsters avatar yungsters commented on April 19, 2024 1

Thanks, @Horaddrim.

Sounds like this question has been resolved.

from idx.

Horaddrim avatar Horaddrim commented on April 19, 2024

Could you provide more details about how exactly it should work? Your issue doesn't say anything 😅 It doesn't work in the transpile fase? Or at the runtime?

from idx.

macalinao avatar macalinao commented on April 19, 2024

This should have no compile errors, but it does.

The error is [ts] Object is possibly 'null'. [2531].

from idx.

Horaddrim avatar Horaddrim commented on April 19, 2024

If you are using the { strict: true } option in your tsconfig.json, it will always check about possible null values, and for never values too, so, if you want to compile your code, you can disable that, or do a check in this variable, because the idx type definition returns a possible null in this line :D
Checking the return here const something = idx(myVar, _ => _.a.b); with something like -> const something = idx(myVar, _ => _.a.b) || 'Error message here'; will solve the problem.

from idx.

macalinao avatar macalinao commented on April 19, 2024

@Horaddrim This doesn't solve the problem for me.

    const myVar: { a: { b: string } } | null = null as {
      a: { b: string };
    } | null;
    const something = idx(myVar, _ => _.a.b) || "TEST";

still fails the build.

Please let me know if I failed any etiquette by opening a new issue. I'm not sure if I was supposed to do that-- sorry if I'm being annoying!

from idx.

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.