Giter VIP home page Giter VIP logo

Comments (4)

zajrik avatar zajrik commented on June 6, 2024

This is invalid. undefined and null are subtypes of all types. Anything and everything can have null or undefined compared to or assigned to it.

https://www.typescriptlang.org/docs/handbook/basic-types.html

Scroll down to the Null and Undefined section for more information.

from discord.js-typings.

Awpteamoose avatar Awpteamoose commented on June 6, 2024

Yes, but --strictNullChecks won't catch it without an explicit definition.

from discord.js-typings.

zajrik avatar zajrik commented on June 6, 2024

Accommodating strictNullChecks in typings is one: an exercise in frustration, and two: not common practice in module typings from what I have seen.

To my knowledge strictNullChecks prevents you from assigning null/undefined to variables declared as anything but null/undefined or from returning them in non-void functions that don't explicitly state it. This does not prevent you from making checks to verify that a returned value is actually null or undefined.

I could be wrong, I suppose but I personally have no intention of throwing | null | undefined union types onto every method return signature.

from discord.js-typings.

arsdragonfly avatar arsdragonfly commented on June 6, 2024

--strictNullChecks forces you to either explicitly handle a potential null value or get a compile-time type error (say you intended to return number, but you're actually returning number | undefined, which is an error). See here: https://www.typescriptlang.org/docs/handbook/advanced-types.html

from discord.js-typings.

Related Issues (18)

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.