| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
|
TypeScript Bot (@typescript-bot) pack this |
Sorry, something went wrong.
|
Starting jobs; this comment will be updated as builds start and complete.
|
Sorry, something went wrong.
| > : ^^^^^^^ | ||
| >value : (T & {}) | null | ||
| > : ^^^^^^^^^^^^^^^ | ||
| >value : (T & ({} | null)) | null |
There was a problem hiding this comment.
this seems to be the only weirder/"I may need to fix that" break that happens in the test suite. This test pre-dates #49119, which adds "An unconstrained type parameter is no longer assignable to {}" and was the cause of the original regression that this PR fixes, so the code in this test doesn't do what the original author probably intended.
Sorry, something went wrong.
|
Hey Isabel Duan (@iisaduan), I've packed this into an installable tgz. You can install it for testing by referencing it in your package.json like so: {
"devDependencies": {
"typescript": "https://typescript.visualstudio.com/cf7ac146-d525-443c-b23c-0d58337efebc/_apis/build/builds/162485/artifacts?artifactName=tgz&fileId=AF28E66001C4F2A54E0E06BA6353BC28CB019DB36741936508D6896D4A5C5F1102&fileName=/typescript-5.6.0-insiders.20240627.tgz"
}
}
and then running npm install. There is also a playground for this build and an npm module you can use via "typescript": "npm:@typescript-deploys/pr-build@5.6.0-pr-59059-2".; |
Sorry, something went wrong.
|
TypeScript Bot (@typescript-bot) test it |
Sorry, something went wrong.
|
Starting jobs; this comment will be updated as builds start and complete.
|
Sorry, something went wrong.
|
Hey Isabel Duan (@iisaduan), the results of running the DT tests are ready. Everything looks the same! |
Sorry, something went wrong.
|
Isabel Duan (@iisaduan) Here are the results of running the user tests with tsc comparing main and refs/pull/59059/merge: Something interesting changed - please have a look. Detailsfp-tstsconfig.json
tsconfig.build-es6.json
examples/tsconfig.json
dtslint/ts3.5/tsconfig.json
puppeteerpackages/puppeteer-core/tsconfig.json
webpacktsconfig.types.json
|
Sorry, something went wrong.
|
Isabel Duan (@iisaduan)
tscComparison Report - baseline..pr
System info unknown
Hosts
Scenarios
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Sorry, something went wrong.
|
Isabel Duan (@iisaduan) Here are the results of running the top 400 repos with tsc comparing main and refs/pull/59059/merge: Something interesting changed - please have a look. Detailsag-grid/ag-grid31 of 110 projects failed to build with the old tsc and were ignored enterprise-modules/viewport-row-model/tsconfig.watch.json
enterprise-modules/viewport-row-model/tsconfig.types.watch.json
enterprise-modules/status-bar/tsconfig.watch.json
enterprise-modules/status-bar/tsconfig.types.watch.json
enterprise-modules/sparklines/tsconfig.watch.json
enterprise-modules/sparklines/tsconfig.types.watch.json
enterprise-modules/side-bar/tsconfig.watch.json
enterprise-modules/side-bar/tsconfig.types.watch.json
enterprise-modules/set-filter/tsconfig.watch.json
enterprise-modules/set-filter/tsconfig.types.watch.json
enterprise-modules/server-side-row-model/tsconfig.watch.json
enterprise-modules/server-side-row-model/tsconfig.types.watch.json
enterprise-modules/row-grouping/tsconfig.watch.json
enterprise-modules/row-grouping/tsconfig.types.watch.json
enterprise-modules/rich-select/tsconfig.watch.json
enterprise-modules/rich-select/tsconfig.types.watch.json
enterprise-modules/range-selection/tsconfig.watch.json
enterprise-modules/range-selection/tsconfig.types.watch.json
enterprise-modules/multi-filter/tsconfig.watch.json
enterprise-modules/multi-filter/tsconfig.types.watch.json
enterprise-modules/master-detail/tsconfig.watch.json
enterprise-modules/master-detail/tsconfig.types.watch.json
enterprise-modules/filter-tool-panel/tsconfig.watch.json
enterprise-modules/filter-tool-panel/tsconfig.types.watch.json
enterprise-modules/core/tsconfig.watch.json
enterprise-modules/core/tsconfig.types.watch.json
enterprise-modules/advanced-filter/tsconfig.watch.json
enterprise-modules/advanced-filter/tsconfig.types.watch.json
community-modules/vue3/tsconfig.watch.json
community-modules/vue3/tsconfig.types.watch.json
community-modules/infinite-row-model/tsconfig.watch.json
community-modules/infinite-row-model/tsconfig.types.watch.json
community-modules/csv-export/tsconfig.watch.json
community-modules/csv-export/tsconfig.types.watch.json
community-modules/core/tsconfig.watch.json
community-modules/core/tsconfig.types.watch.json
community-modules/client-side-row-model/tsconfig.watch.json
community-modules/client-side-row-model/tsconfig.types.watch.json
compiler-explorer/compiler-explorer2 of 6 projects failed to build with the old tsc and were ignored tsconfig.tests.json
tsconfig.json
static/tsconfig.json
desktop/desktop1 of 4 projects failed to build with the old tsc and were ignored tsconfig.json
discordjs/discord.js39 of 62 projects failed to build with the old tsc and were ignored packages/collection/tsconfig.json
packages/collection/tsconfig.eslint.json
packages/collection/tsconfig.docs.json
gcanti/fp-ts4 of 5 projects failed to build with the old tsc and were ignored tsconfig.build-es6.json
Infisical/infisical1 of 2 projects failed to build with the old tsc and were ignored backend/tsconfig.json
microsoft/vscode4 of 54 projects failed to build with the old tsc and were ignored src/tsconfig.tsec.json
src/tsconfig.json
motion-canvas/motion-canvas13 of 18 projects failed to build with the old tsc and were ignored packages/core/tsconfig.json
packages/core/tsconfig.build.json
|
Sorry, something went wrong.
Sorry, something went wrong.
…constrainedTypeParameter
|
With this PR, this lint check is necessary, as it was what was causing the self-check to fail earlier https://github.com/microsoft/TypeScript/actions/runs/9751008069/job/26911678446 |
Sorry, something went wrong.
|
So one of the things that no longer works is the following: function f<T, K extends keyof T>(obj: T, key: K) {
return obj[key];
// ~~~
// error! 'obj' is possibly 'null' or 'undefined'.
}One of the reasons we've typically said that this is okay is because keyof undefined or keyof null is never; so even it's not really unsafe because it's supposed to be impossible to call f in a reasonable way (with some caveats). f(undefined, "hello");
// ~~~~~~~
// error! Argument of type 'string' is not assignable to parameter of type 'never'.I know Anders Hejlsberg (@ahejlsberg) was considering changing this for other reasons around the time that #56652 was out. Maybe he has some thoughts here or can give some pointers. I think we can fix #50603 well enough without disrupting the behaviors in place, but I'd have to take a deeper look to help out there. |
Sorry, something went wrong.
Thanks for the insight! I think so too, I will fix that. Those test cases looked alright at first, but after you brought the above up, I was reminded that the following is similarish and fine function f<T>(obj: T) {
for (const key in obj) {
obj[key]; // no errors
}
} |
Sorry, something went wrong.
|
TypeScript Bot (@typescript-bot) test it |
Sorry, something went wrong.
|
Starting jobs; this comment will be updated as builds start and complete.
|
Sorry, something went wrong.
|
Hey Isabel Duan (@iisaduan), the results of running the DT tests are ready. Everything looks the same! |
Sorry, something went wrong.
|
Isabel Duan (@iisaduan) Here are the results of running the user tests with tsc comparing main and refs/pull/59059/merge: Something interesting changed - please have a look. Detailsfp-tstsconfig.json
tsconfig.build-es6.json
webpacktsconfig.types.json
|
Sorry, something went wrong.
|
Isabel Duan (@iisaduan)
tscComparison Report - baseline..pr
System info unknown
Hosts
Scenarios
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Sorry, something went wrong.
|
Isabel Duan (@iisaduan) Here are the results of running the top 400 repos with tsc comparing main and refs/pull/59059/merge: Something interesting changed - please have a look. Detailsag-grid/ag-grid31 of 110 projects failed to build with the old tsc and were ignored enterprise-modules/viewport-row-model/tsconfig.watch.json
enterprise-modules/viewport-row-model/tsconfig.types.watch.json
enterprise-modules/status-bar/tsconfig.watch.json
enterprise-modules/status-bar/tsconfig.types.watch.json
enterprise-modules/sparklines/tsconfig.watch.json
enterprise-modules/sparklines/tsconfig.types.watch.json
enterprise-modules/side-bar/tsconfig.watch.json
enterprise-modules/side-bar/tsconfig.types.watch.json
enterprise-modules/set-filter/tsconfig.watch.json
enterprise-modules/set-filter/tsconfig.types.watch.json
enterprise-modules/server-side-row-model/tsconfig.watch.json
enterprise-modules/server-side-row-model/tsconfig.types.watch.json
enterprise-modules/row-grouping/tsconfig.watch.json
enterprise-modules/row-grouping/tsconfig.types.watch.json
enterprise-modules/rich-select/tsconfig.watch.json
enterprise-modules/rich-select/tsconfig.types.watch.json
enterprise-modules/range-selection/tsconfig.watch.json
enterprise-modules/range-selection/tsconfig.types.watch.json
enterprise-modules/multi-filter/tsconfig.watch.json
enterprise-modules/multi-filter/tsconfig.types.watch.json
enterprise-modules/master-detail/tsconfig.watch.json
enterprise-modules/master-detail/tsconfig.types.watch.json
enterprise-modules/filter-tool-panel/tsconfig.watch.json
enterprise-modules/filter-tool-panel/tsconfig.types.watch.json
enterprise-modules/core/tsconfig.watch.json
enterprise-modules/core/tsconfig.types.watch.json
enterprise-modules/advanced-filter/tsconfig.watch.json
enterprise-modules/advanced-filter/tsconfig.types.watch.json
community-modules/vue3/tsconfig.watch.json
community-modules/vue3/tsconfig.types.watch.json
community-modules/infinite-row-model/tsconfig.watch.json
community-modules/infinite-row-model/tsconfig.types.watch.json
community-modules/csv-export/tsconfig.watch.json
community-modules/csv-export/tsconfig.types.watch.json
community-modules/core/tsconfig.watch.json
community-modules/core/tsconfig.types.watch.json
community-modules/client-side-row-model/tsconfig.watch.json
community-modules/client-side-row-model/tsconfig.types.watch.json
compiler-explorer/compiler-explorer2 of 6 projects failed to build with the old tsc and were ignored tsconfig.tests.json
tsconfig.json
static/tsconfig.json
desktop/desktop1 of 4 projects failed to build with the old tsc and were ignored tsconfig.json
discordjs/discord.js39 of 62 projects failed to build with the old tsc and were ignored packages/collection/tsconfig.json
packages/collection/tsconfig.eslint.json
packages/collection/tsconfig.docs.json
gcanti/fp-ts2 of 5 projects failed to build with the old tsc and were ignored tsconfig.json
tsconfig.build-es6.json
Infisical/infisical1 of 2 projects failed to build with the old tsc and were ignored backend/tsconfig.json
sequelize/sequelize13 of 16 projects failed to build with the old tsc and were ignored packages/utils/tsconfig.json
|
Sorry, something went wrong.
|
Daniel Rosenwasser (@DanielRosenwasser) interestingly, this is also a current issue (5.5.3, playground) when T explicitly extends {} | null | undefined: function f<T extends {} | null | undefined , K extends keyof T>(obj: T, key: K) {
return obj[key];
~~~
!!! error TS18049: 'obj' is possibly 'null' or 'undefined'.
~~~~~~~~
!!! error TS2536: Type 'K' cannot be used to index type '{}'.
} |
Sorry, something went wrong.
|
TypeScript Bot (@typescript-bot) test top400 |
Sorry, something went wrong.
|
Starting jobs; this comment will be updated as builds start and complete.
|
Sorry, something went wrong.
|
Isabel Duan (@iisaduan) Here are the results of running the user tests with tsc comparing main and refs/pull/59059/merge: Something interesting changed - please have a look. Detailsazure-sdk/mnt/ts_downloads/_/m/azure-sdk/build.sh
bluebird/mnt/ts_downloads/_/m/bluebird/tsconfig.json
effecttsconfig.json
tsconfig.build.json
tsconfig.base.json
fp-tstsconfig.json
tsconfig.build-es6.json
lodash/mnt/ts_downloads/_/m/lodash/tsconfig.json
webpacktsconfig.types.json
xterm.jssrc/tsconfig-library-base.json
|
Sorry, something went wrong.
|
Looks like #50603 is being addressed in #59352 (and I'll comment on that separately there). Meanwhile, in the example function f<T, K extends keyof T>(obj: T, key: K) {
return obj[key]; // Ok
}
function g<T extends {} | null | undefined , K extends keyof T>(obj: T, key: K) {
return obj[key]; // Error, 'obj' is possibly 'null' or 'undefined'.
}the second error really shouldn't be there. As Daniel Rosenwasser (@DanielRosenwasser) points out above, for any T that includes null or undefined, keyof T is never, so it isn't possible to have a value of type K that would cause the code to fail. In fact, in an obj[key] expression, when key is a valid property name for obj, it must be because obj is of a non-nullable type. That said, the non-nullability check produces nicer and more understandable error messages, so we want to keep it when obj is of a non-generic type. I will put up a PR that fixes that. |
Sorry, something went wrong.
|
With 6.0 out as the final release vehicle for this codebase, we're closing all PRs that don't fit the merge criteria for post-6.0 patches. If you think this was a mistake and this PR fits the post-6.0 patch criteria, please post to the 6.0 iteration issue with details (specifically, which PR and which patch criteria it satisfies). Next steps for PRs:
|
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
fixes #50603
This behavior is due to a case that was unchecked in #49119. (Relevant summary of 49119:
The behavior was previously inconsistent, as shown in the cases below (5.5.3 playground):
Implementation:
This PR
Considerations left
-- in function f<T, U extends T>, U is not an unconstrained parameter
-- (CFA needed?) to check previously ok cases (see tests/baselines/reference/isomorphicMappedTypeInference.errors.txt)
-- const b = "foo" in obj[key]; is no longer okay when we have parameter (obj: T) (see keyofAndIndexedAccessErrors.txt)