Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add undefined to optional properties, React to Regenerate #54352

Merged

Conversation

sandersn
Copy link
Contributor

@sandersn sandersn commented Jul 7, 2021

In preparation for exactOptionalPropertyTypes in Typescript 4.4, add undefined to all optional properties. #no-publishing-comment

This PR covers widely used packages, those with more then 100,000 packages per month, from react-slider -- regenerate

microsoft/dtslint#335

In preparation for exactOptionalPropertyTypes in Typescript 4.4, add undefined to all optional properties. #no-publishing-comment

This PR covers widely used packages, those with more then 100,000 packages per month, from react-slider -- regenerate

microsoft/dtslint#335
@typescript-bot
Copy link
Contributor

typescript-bot commented Jul 7, 2021

@sandersn Thank you for submitting this PR!

This is a live comment which I will keep updated.

30 packages in this PR

Code Reviews

Because this is a widely-used package, a DT maintainer will need to review it before it can be merged.

You can test the changes of this PR in the Playground.

Status

  • ✅ No merge conflicts
  • ❌ Continuous integration tests have failed
  • 🕐 A DT maintainer needs to approve changes which affect more than one package

Once every item on this list is checked, I'll ask you for permission to merge and publish the changes.


Diagnostic Information: What the bot saw about this PR
{
  "type": "info",
  "now": "-",
  "pr_number": 54352,
  "author": "sandersn",
  "headCommitOid": "bd29f99cb5e12c080e48ca611f8f3907574aa025",
  "lastPushDate": "2021-07-07T17:49:41.000Z",
  "lastActivityDate": "2021-07-07T17:49:41.000Z",
  "hasMergeConflict": false,
  "isFirstContribution": false,
  "tooManyFiles": false,
  "popularityLevel": "Critical",
  "pkgInfo": [
    {
      "name": "react-slider",
      "kind": "edit",
      "files": [
        {
          "path": "types/react-slider/index.d.ts",
          "kind": "definition"
        }
      ],
      "owners": [
        "jsonunger",
        "bjorgvin",
        "loichuder",
        "axelboc"
      ],
      "addedOwners": [],
      "deletedOwners": [],
      "popularityLevel": "Well-liked by everyone"
    },
    {
      "name": "react-sticky",
      "kind": "edit",
      "files": [
        {
          "path": "types/react-sticky/index.d.ts",
          "kind": "definition"
        }
      ],
      "owners": [
        "curtisw0",
        "ajhyndman"
      ],
      "addedOwners": [],
      "deletedOwners": [],
      "popularityLevel": "Well-liked by everyone"
    },
    {
      "name": "react-stripe-elements",
      "kind": "edit",
      "files": [
        {
          "path": "types/react-stripe-elements/index.d.ts",
          "kind": "definition"
        }
      ],
      "owners": [
        "dan-j",
        "santiagodoldan",
        "sonnysangha",
        "9y5",
        "thchia",
        "yhnavein",
        "virzak",
        "remotealex",
        "bombek92",
        "hirochachacha",
        "paustint",
        "mastacheata"
      ],
      "addedOwners": [],
      "deletedOwners": [],
      "popularityLevel": "Popular"
    },
    {
      "name": "react-swipeable-views-utils",
      "kind": "edit",
      "files": [
        {
          "path": "types/react-swipeable-views-utils/index.d.ts",
          "kind": "definition"
        }
      ],
      "owners": [
        "eps1lon",
        "robertnisipeanu"
      ],
      "addedOwners": [],
      "deletedOwners": [],
      "popularityLevel": "Popular"
    },
    {
      "name": "react-swipeable-views",
      "kind": "edit",
      "files": [
        {
          "path": "types/react-swipeable-views/index.d.ts",
          "kind": "definition"
        }
      ],
      "owners": [
        "mxl",
        "DeividasBakanas"
      ],
      "addedOwners": [],
      "deletedOwners": [],
      "popularityLevel": "Popular"
    },
    {
      "name": "react-syntax-highlighter",
      "kind": "edit",
      "files": [
        {
          "path": "types/react-syntax-highlighter/index.d.ts",
          "kind": "definition"
        }
      ],
      "owners": [
        "NoHomey",
        "guoyunhe",
        "anirban09",
        "michaelyuen"
      ],
      "addedOwners": [],
      "deletedOwners": [],
      "popularityLevel": "Critical"
    },
    {
      "name": "react-table",
      "kind": "edit",
      "files": [
        {
          "path": "types/react-table/index.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/react-table/react-table-tests.tsx",
          "kind": "test"
        },
        {
          "path": "types/react-table/v6/index.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/react-table/v6/lib/hoc/selectTable.d.ts",
          "kind": "definition"
        }
      ],
      "owners": [
        "ggascoigne",
        "stramel",
        "gargroh",
        "riceboyler"
      ],
      "addedOwners": [],
      "deletedOwners": [],
      "popularityLevel": "Popular"
    },
    {
      "name": "react-tabs",
      "kind": "edit",
      "files": [
        {
          "path": "types/react-tabs/index.d.ts",
          "kind": "definition"
        }
      ],
      "owners": [
        "yu-i9",
        "danez",
        "Equationist"
      ],
      "addedOwners": [],
      "deletedOwners": [],
      "popularityLevel": "Popular"
    },
    {
      "name": "react-text-mask",
      "kind": "edit",
      "files": [
        {
          "path": "types/react-text-mask/index.d.ts",
          "kind": "definition"
        }
      ],
      "owners": [
        "guilhermehubner",
        "cavarzan",
        "needpower"
      ],
      "addedOwners": [],
      "deletedOwners": [],
      "popularityLevel": "Popular"
    },
    {
      "name": "react-textarea-autosize",
      "kind": "edit",
      "files": [
        {
          "path": "types/react-textarea-autosize/index.d.ts",
          "kind": "definition"
        }
      ],
      "owners": [
        "asvetliakov",
        "zry656565",
        "Rahul-Sagore"
      ],
      "addedOwners": [],
      "deletedOwners": [],
      "popularityLevel": "Popular"
    },
    {
      "name": "react-toggle",
      "kind": "edit",
      "files": [
        {
          "path": "types/react-toggle/index.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/react-toggle/v2/index.d.ts",
          "kind": "definition"
        }
      ],
      "owners": [
        "LKay"
      ],
      "addedOwners": [],
      "deletedOwners": [],
      "popularityLevel": "Popular"
    },
    {
      "name": "react-transition-group",
      "kind": "edit",
      "files": [
        {
          "path": "types/react-transition-group/CSSTransition.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/react-transition-group/SwitchTransition.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/react-transition-group/Transition.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/react-transition-group/TransitionGroup.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/react-transition-group/react-transition-group-tests.tsx",
          "kind": "test"
        },
        {
          "path": "types/react-transition-group/v1/CSSTransitionGroup.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/react-transition-group/v1/index.d.ts",
          "kind": "definition"
        }
      ],
      "owners": [
        "LKay",
        "Epskampie",
        "ybiquitous",
        "tu4mo",
        "bengry"
      ],
      "addedOwners": [],
      "deletedOwners": [],
      "popularityLevel": "Critical"
    },
    {
      "name": "react-truncate",
      "kind": "edit",
      "files": [
        {
          "path": "types/react-truncate/index.d.ts",
          "kind": "definition"
        }
      ],
      "owners": [
        "mattvperry"
      ],
      "addedOwners": [],
      "deletedOwners": [],
      "popularityLevel": "Popular"
    },
    {
      "name": "react-virtualized-auto-sizer",
      "kind": "edit",
      "files": [
        {
          "path": "types/react-virtualized-auto-sizer/index.d.ts",
          "kind": "definition"
        }
      ],
      "owners": [
        "otofu-square"
      ],
      "addedOwners": [],
      "deletedOwners": [],
      "popularityLevel": "Popular"
    },
    {
      "name": "react-virtualized",
      "kind": "edit",
      "files": [
        {
          "path": "types/react-virtualized/dist/es/ArrowKeyStepper.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/react-virtualized/dist/es/AutoSizer.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/react-virtualized/dist/es/CellMeasurer.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/react-virtualized/dist/es/Collection.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/react-virtualized/dist/es/ColumnSizer.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/react-virtualized/dist/es/Grid.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/react-virtualized/dist/es/InfiniteLoader.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/react-virtualized/dist/es/List.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/react-virtualized/dist/es/Masonry.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/react-virtualized/dist/es/MultiGrid.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/react-virtualized/dist/es/Table.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/react-virtualized/dist/es/WindowScroller.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/react-virtualized/react-virtualized-tests.tsx",
          "kind": "test"
        }
      ],
      "owners": [
        "kaoDev",
        "guntherjh",
        "wasd171",
        "szabolcsx",
        "Stevearzh",
        "mgoszcz2",
        "brandonhall",
        "sbusch",
        "azmenak"
      ],
      "addedOwners": [],
      "deletedOwners": [],
      "popularityLevel": "Popular"
    },
    {
      "name": "react-window-infinite-loader",
      "kind": "edit",
      "files": [
        {
          "path": "types/react-window-infinite-loader/index.d.ts",
          "kind": "definition"
        }
      ],
      "owners": [
        "Nibblesh",
        "fnknzzz"
      ],
      "addedOwners": [],
      "deletedOwners": [],
      "popularityLevel": "Popular"
    },
    {
      "name": "react-window",
      "kind": "edit",
      "files": [
        {
          "path": "types/react-window/index.d.ts",
          "kind": "definition"
        }
      ],
      "owners": [
        "martynaskadisa",
        "heyimalex",
        "jgoz"
      ],
      "addedOwners": [],
      "deletedOwners": [],
      "popularityLevel": "Popular"
    },
    {
      "name": "react",
      "kind": "edit",
      "files": [
        {
          "path": "types/react/index.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/react/next.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/react/test/hooks.tsx",
          "kind": "test"
        },
        {
          "path": "types/react/test/index.ts",
          "kind": "test"
        },
        {
          "path": "types/react/test/tsx.tsx",
          "kind": "test"
        },
        {
          "path": "types/react/v15/index.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/react/v15/test/index.ts",
          "kind": "test"
        },
        {
          "path": "types/react/v15/test/tsx.tsx",
          "kind": "test"
        },
        {
          "path": "types/react/v16/index.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/react/v16/test/hooks.tsx",
          "kind": "test"
        },
        {
          "path": "types/react/v16/test/index.ts",
          "kind": "test"
        },
        {
          "path": "types/react/v16/test/tsx.tsx",
          "kind": "test"
        }
      ],
      "owners": [
        "johnnyreilly",
        "bbenezech",
        "pzavolinsky",
        "ericanderson",
        "DovydasNavickas",
        "theruther4d",
        "guilhermehubner",
        "ferdaber",
        "jrakotoharisoa",
        "pascaloliv",
        "hotell",
        "franklixuefei",
        "Jessidhia",
        "saranshkataria",
        "lukyth",
        "eps1lon",
        "zieka",
        "dancerphil",
        "dimitropoulos",
        "disjukr",
        "vhfmag",
        "hellatan",
        "priyanshurav"
      ],
      "addedOwners": [],
      "deletedOwners": [],
      "popularityLevel": "Critical"
    },
    {
      "name": "reactcss",
      "kind": "edit",
      "files": [
        {
          "path": "types/reactcss/index.d.ts",
          "kind": "definition"
        }
      ],
      "owners": [
        "chrisgervang",
        "LKay"
      ],
      "addedOwners": [],
      "deletedOwners": [],
      "popularityLevel": "Popular"
    },
    {
      "name": "readable-stream",
      "kind": "edit",
      "files": [
        {
          "path": "types/readable-stream/index.d.ts",
          "kind": "definition"
        }
      ],
      "owners": [
        "TeamworkGuy2",
        "markdreyer"
      ],
      "addedOwners": [],
      "deletedOwners": [],
      "popularityLevel": "Popular"
    },
    {
      "name": "readline-sync",
      "kind": "edit",
      "files": [
        {
          "path": "types/readline-sync/index.d.ts",
          "kind": "definition"
        }
      ],
      "owners": [
        "jonestristand"
      ],
      "addedOwners": [],
      "deletedOwners": [],
      "popularityLevel": "Well-liked by everyone"
    },
    {
      "name": "rebass",
      "kind": "edit",
      "files": [
        {
          "path": "types/rebass/index.d.ts",
          "kind": "definition"
        }
      ],
      "owners": [
        "rhysd",
        "ryee-dev",
        "jamesmckenzie",
        "gretzky",
        "angusfretwell",
        "orzarchi",
        "ilaiwi",
        "mrkosima",
        "rafaelalmeidatk"
      ],
      "addedOwners": [],
      "deletedOwners": [],
      "popularityLevel": "Well-liked by everyone"
    },
    {
      "name": "recompose",
      "kind": "edit",
      "files": [
        {
          "path": "types/recompose/index.d.ts",
          "kind": "definition"
        }
      ],
      "owners": [
        "iskandersierra",
        "clayne11",
        "Pajn",
        "lucasterra",
        "brian-lives-outdoors",
        "TiuSh"
      ],
      "addedOwners": [],
      "deletedOwners": [],
      "popularityLevel": "Popular"
    },
    {
      "name": "redis",
      "kind": "edit",
      "files": [
        {
          "path": "types/redis/index.d.ts",
          "kind": "definition"
        }
      ],
      "owners": [
        "soywiz",
        "CodeAnimal",
        "MugeSo",
        "UppaJung",
        "Rokt33r",
        "43081j",
        "barnski",
        "1pete",
        "blablapolicja",
        "ferrantejake",
        "OpesanyaAdebayo",
        "nwtgck",
        "tdebarochez",
        "dwrss"
      ],
      "addedOwners": [],
      "deletedOwners": [],
      "popularityLevel": "Popular"
    },
    {
      "name": "redlock",
      "kind": "edit",
      "files": [
        {
          "path": "types/redlock/index.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/redlock/v2/index.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/redlock/v3/index.d.ts",
          "kind": "definition"
        }
      ],
      "owners": [
        "chrootsu",
        "BendingBender",
        "douglascayers"
      ],
      "addedOwners": [],
      "deletedOwners": [],
      "popularityLevel": "Popular"
    },
    {
      "name": "redux-actions",
      "kind": "edit",
      "files": [
        {
          "path": "types/redux-actions/index.d.ts",
          "kind": "definition"
        }
      ],
      "owners": [
        "jaysoo",
        "alexgorbatchev",
        "alechill",
        "alexey-pelykh",
        "7hi4g0",
        "oddui"
      ],
      "addedOwners": [],
      "deletedOwners": [],
      "popularityLevel": "Popular"
    },
    {
      "name": "redux-form",
      "kind": "edit",
      "files": [
        {
          "path": "types/redux-form/index.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/redux-form/lib/Field.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/redux-form/lib/FieldArray.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/redux-form/lib/Fields.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/redux-form/lib/Form.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/redux-form/lib/FormName.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/redux-form/lib/FormSection.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/redux-form/lib/reducer.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/redux-form/lib/reduxForm.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/redux-form/redux-form-tests.tsx",
          "kind": "test"
        },
        {
          "path": "types/redux-form/v4/index.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/redux-form/v5/index.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/redux-form/v6/index.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/redux-form/v6/lib/Field.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/redux-form/v6/lib/FieldArray.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/redux-form/v6/lib/Fields.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/redux-form/v6/lib/reducer.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/redux-form/v6/lib/reduxForm.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/redux-form/v6/redux-form-tests.tsx",
          "kind": "test"
        },
        {
          "path": "types/redux-form/v7/index.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/redux-form/v7/lib/Field.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/redux-form/v7/lib/FieldArray.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/redux-form/v7/lib/Fields.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/redux-form/v7/lib/Form.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/redux-form/v7/lib/FormSection.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/redux-form/v7/lib/reducer.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/redux-form/v7/lib/reduxForm.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/redux-form/v7/redux-form-tests.tsx",
          "kind": "test"
        }
      ],
      "owners": [
        "aikoven",
        "LKay",
        "bancek",
        "tehbi4",
        "huwmartin",
        "m-b-davis",
        "ethanresnick",
        "maddijoyce",
        "smifun",
        "mshaaban088",
        "esetnik",
        "mrsekut",
        "abemedia"
      ],
      "addedOwners": [],
      "deletedOwners": [],
      "popularityLevel": "Popular"
    },
    {
      "name": "redux-logger",
      "kind": "edit",
      "files": [
        {
          "path": "types/redux-logger/index.d.ts",
          "kind": "definition"
        }
      ],
      "owners": [
        "arusakov",
        "kgroat"
      ],
      "addedOwners": [],
      "deletedOwners": [],
      "popularityLevel": "Popular"
    },
    {
      "name": "refractor",
      "kind": "edit",
      "files": [
        {
          "path": "types/refractor/core.d.ts",
          "kind": "definition"
        }
      ],
      "owners": [
        "ifiokjr"
      ],
      "addedOwners": [],
      "deletedOwners": [],
      "popularityLevel": "Well-liked by everyone"
    },
    {
      "name": "regenerate",
      "kind": "edit",
      "files": [
        {
          "path": "types/regenerate/index.d.ts",
          "kind": "definition"
        }
      ],
      "owners": [
        "ExE-Boss"
      ],
      "addedOwners": [],
      "deletedOwners": [],
      "popularityLevel": "Popular"
    }
  ],
  "reviews": [],
  "mainBotCommentID": 875788664,
  "ciResult": "fail",
  "ciUrl": "https://github.com/DefinitelyTyped/DefinitelyTyped/commit/bd29f99cb5e12c080e48ca611f8f3907574aa025/checks?check_suite_id=3181791212"
}

@typescript-bot
Copy link
Contributor

⚠️ There are too many reviewers for this PR change (139). Merging can only be handled by a DT maintainer.

People who would have been pinged jsonunger bjorgvin loichuder axelboc curtisw0 ajhyndman dan-j santiagodoldan sonnysangha 9y5 thchia yhnavein virzak remotealex bombek92 hirochachacha paustint mastacheata eps1lon robertnisipeanu mxl DeividasBakanas NoHomey guoyunhe anirban09 michaelyuen ggascoigne stramel gargroh riceboyler yu-i9 danez Equationist guilhermehubner cavarzan needpower asvetliakov zry656565 Rahul-Sagore LKay Epskampie ybiquitous tu4mo bengry mattvperry otofu-square kaoDev guntherjh wasd171 szabolcsx Stevearzh mgoszcz2 brandonhall sbusch azmenak Nibblesh fnknzzz martynaskadisa heyimalex jgoz johnnyreilly bbenezech pzavolinsky ericanderson DovydasNavickas theruther4d ferdaber jrakotoharisoa pascaloliv hotell franklixuefei Jessidhia saranshkataria lukyth zieka dancerphil dimitropoulos disjukr vhfmag hellatan priyanshurav chrisgervang TeamworkGuy2 markdreyer jonestristand rhysd ryee-dev jamesmckenzie gretzky angusfretwell orzarchi ilaiwi mrkosima rafaelalmeidatk iskandersierra clayne11 Pajn lucasterra brian-lives-outdoors TiuSh soywiz CodeAnimal MugeSo UppaJung Rokt33r 43081j barnski 1pete blablapolicja ferrantejake OpesanyaAdebayo nwtgck tdebarochez dwrss chrootsu BendingBender douglascayers jaysoo alexgorbatchev alechill alexey-pelykh 7hi4g0 oddui aikoven bancek tehbi4 huwmartin m-b-davis ethanresnick maddijoyce smifun mshaaban088 esetnik mrsekut abemedia arusakov kgroat ifiokjr ExE-Boss

@typescript-bot typescript-bot added the The CI failed When GH Actions fails label Jul 7, 2021
@typescript-bot typescript-bot moved this from Waiting for Code Reviews to Needs Author Action in New Pull Request Status Board Jul 7, 2021
@typescript-bot
Copy link
Contributor

@sandersn The CI build failed! Please review the logs for more information.

Once you've pushed the fixes, the build will automatically re-run. Thanks!

Note: builds which are failing do not end up on the list of PRs for the DT maintainers to review.

@sandersn
Copy link
Contributor Author

sandersn commented Jul 7, 2021

Failure is from a dependent of mongoose, which fails on master as well.

@sandersn sandersn merged commit d4f392f into master Jul 7, 2021
@sandersn sandersn deleted the React-Regenerate-add-undefined-to-optional-properties branch July 7, 2021 18:25
@typescript-bot typescript-bot removed this from Needs Author Action in New Pull Request Status Board Jul 7, 2021
@kokushkin
Copy link
Contributor

Just wonder why did you do this? Looks like it wasn't a breaking change in TS 4.4 (flag exactOptionalPropertyTypes : false by default), isn't it? So, everything would be ok until somebody decided to make exactOptionalPropertyTypes : true but then they could deal with it in their own code just fine. On another side now I see a lot of | undefined in React types which definitely troubles my understanding even more (they where hard enough before that). (I tried to read microsoft/dtslint#335 I didn't get the explanation though)

@sandersn
Copy link
Contributor Author

sandersn commented Oct 18, 2021

but then they could deal with it in their own code just fine

No, if you pass undefined to a package it needs to explicitly allow undefined if you have the flag on.

React types often do distinguish between optional and undefined, and will need to be updated in a separate pass.

@johnnyreilly
Copy link
Member

Failure is from a dependent of mongoose, which fails on master as well.

Taken in isolation, this one comment feels like an abstract poem 😉

@kokushkin
Copy link
Contributor

kokushkin commented Oct 19, 2021

No, if you pass undefined to a package it needs to explicitly allow undefined if you have the flag on.

I mean why wouldn't they pass nothing instead of undefined if they turned on the flag? Why package , in this case React had to do something with it?

React types often do distinguish between optional and undefined, and will need to be updated in a separate pass.

hm.. I think it's something unclear here. Do you say that for "proper use" of React in TS you need to have the flag turned on, overwise in the places where React "do distinguish between optional and undefined" (where it should be "?" or "| undefined" but not both!) you might not notice an error?

@sandersn
Copy link
Contributor Author

I mean why wouldn't they pass nothing instead of undefined if they turned on the flag?

They might have lots of incorrect code that already passes undefined instead of nothing.

Do you say that for "proper use" of React in TS you need to have the flag turned on, overwise in the places where React "do distinguish between optional and undefined" (where it should be "?" or "| undefined" but not both!) you might not notice an error?

Yes, and this wasn't possible until recently, so adding | undefined to DT types makes the transition easier.

@kokushkin
Copy link
Contributor

kokushkin commented Oct 19, 2021

They might have lots of incorrect code that already passes undefined instead of nothing.

yeah, of course, but this is a new major version I suppose and people should expect breaking changes. I understand it's a tradeoff but.. such important types in such an important library! Though people don't have their code broken now it might have bad consequences in the future if such things happen too often, I think. Interesting thing to think about anyway.

Yes, and this wasn't possible until recently, so adding | undefined to DT types makes the transition easier.

Ok, but something feels wrong anyway when I see a lot of blablabla?: type | undefined. Maybe it's the redundacy of the construction itself. Let's say I'm creating a new field in my library, and I don't care about whether it might be nothing or undefined, so what am I gonna do know? Of course blablabla?: type | undefined . But how I'd like to do it instead? Probably just blablabla?: type would be easier, right? And blablabla: type | undefined if I'll not accept "no field" . And the last thing to do is to say "I'll accept no field but not undefined" might be something blablabla: NonNullable<type> | null (not sure if it's ever been needed even) I not sure about correctness of the last one but the point here is to make the most often used things the most simple. Now it's kind of opposite, would you agree with that?

@sandersn
Copy link
Contributor Author

it might have bad consequences in the future if such things happen too often, I think

We don't intend to edit every package on DT very often, no fear. =)

Unfortunately backward compatibility means the "don't care" semantics are longer to write. We would definitely do it the other way if we started over from scratch.

@kokushkin
Copy link
Contributor

So do you think it's gonna stay till the end of Typescript? And it's too big change even for a new major version or couple of such? And this's kind of a relatively new stuff, not even one year ago, right? I mean introducing the exactOptionalPropertyTypes flag, starting from which all these "don't care cases" ( I think they constitute over 99% of all cases) should be written like blablabla?: type | undefined. So there was no way to say "I'll accept nothing but not undefined", correct? Could you please point me out to the issue where exactOptionalPropertyTypes was conceived?) I really want to know what were the discussions behind this.

@sandersn
Copy link
Contributor Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants