-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Use homomorphic templated type for Omit
#53110
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
Conversation
# Conflicts: # package-lock.json # package.json # src/compiler/checker.ts # tests/baselines/reference/omitTypeHelperModifiers01.types # tests/baselines/reference/omitTypeTestErrors01.types # tests/baselines/reference/omitTypeTests01.types
|
Extremely curious what this breaks 😅 @typescript-bot test this |
|
Heya @RyanCavanaugh, I've started to run the extended test suite on this PR at c823418. You can monitor the build here. |
|
Heya @RyanCavanaugh, I've started to run the diff-based user code test suite (tsserver) on this PR at c823418. You can monitor the build here. Update: The results are in! |
|
Heya @RyanCavanaugh, I've started to run the parallelized Definitely Typed test suite on this PR at c823418. You can monitor the build here. Update: The results are in! |
|
Heya @RyanCavanaugh, I've started to run the perf test suite on this PR at c823418. You can monitor the build here. Update: The results are in! |
|
Heya @RyanCavanaugh, I've started to run the diff-based top-repos suite on this PR at c823418. You can monitor the build here. Update: The results are in! |
|
Heya @RyanCavanaugh, I've started to run the diff-based user code test suite on this PR at c823418. You can monitor the build here. Update: The results are in! |
|
@RyanCavanaugh Here are the results of running the user test suite comparing Something interesting changed - please have a look. Details
|
|
@RyanCavanaugh Here are the results of running the user test suite comparing Something interesting changed - please have a look. Detailsaxios-src
|
|
@RyanCavanaugh Here they are:
CompilerComparison Report - main..53110
System
Hosts
Scenarios
TSServerComparison Report - main..53110
System
Hosts
Scenarios
StartupComparison Report - main..53110
System
Hosts
Scenarios
Developer Information: |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
I'll investigate what the user test suite has discovered - just 2 projects were affected... ain't that bad :P Perf numbers don't look that great though but perhaps there are some low-hanging fruits to be found here for mapped types with |
|
Relevant line from export interface HttpsProxyAgentOptions extends AgentOptions, BaseHttpsProxyAgentOptions, Partial<Omit<Url & net.NetConnectOpts & tls.ConnectionOptions, keyof BaseHttpsProxyAgentOptions>> {
} |
|
Regarding the other reported problem in TypeScript-Node-Starter... it doesn't happen with the newest version of |
|
@RyanCavanaugh Here are the results of running the top-repos suite comparing Something interesting changed - please have a look. Details
|
|
@RyanCavanaugh Here are the results of running the top-repos suite comparing Something interesting changed - please have a look. Detailsakveo/ngx-admin
|
|
@RyanCavanaugh Here are some more interesting changes from running the top-repos suite Detailshasura/graphql-engine
|
|
@RyanCavanaugh Here are some more interesting changes from running the top-repos suite Detailspnpm/pnpm
|
|
@RyanCavanaugh Here are some more interesting changes from running the top-repos suite Detailssolidjs/solid
|
|
Hey @RyanCavanaugh, the results of running the DT tests are ready. Branch only errors:Package: mongoose-aggregate-paginate-v2 Package: mongoose-delete Package: mongoose-sequence Package: mongoose-mock Package: multer-gridfs-storage/v3 Package: diffie-hellman Package: mongoose-auto-increment Package: mongoose-geojson-schema Package: mongoose-simple-random Package: mongoose-paginate Package: passport-local-mongoose Package: js2coffee Package: koa2-ratelimit Package: material-ui-phone-number Package: mongoose-autopopulate Package: mongoose-id-validator Package: mongoose-unique-validator Package: wordpress__editor Package: forest-express-mongoose Package: mongoose-lean-virtuals Package: mongoose-deep-populate Package: multer-gridfs-storage |
|
I'll continue to investigate the incoming reports but so far I've encountered some really surprising things here. The As mentioned, the |
|
Homomorphic mapped types distribute over unions, whereas the thing you get out of the current type Tmp = Omit<net.NetConnectOpts, never>;
// ^ resolves to a regular object type
export interface HttpsProxyAgentOptions2 extends Tmp {} |
|
Expanding on the previous point... the new type Omit2<T, K extends keyof any> = {
[P in keyof T as Exclude<P, K>]: T[P];
};
type ABC = {
a: string,
b: string,
c: string
};
type BCD = {
b: string,
c: string,
d: string
};
interface JustB extends Omit<ABC | BCD, "c"> { }
const b: JustB = { b: "" };
type AB_or_BD = Omit2<ABC | BCD, "c">;
const ab: AB_or_BD = { a: "", b: "" };
const bd: AB_or_BD = { b: "", d: "" }; |
Ah ye, of course 🤦♂️ That means though that #36981 should just be closed with the explainer about different flavours of |
|
I think there have been several requests in the past for a distributive |
|
Oh, ye - definitely. @RyanCavanaugh's work supersedes this. |
I almost prepared the same change but then noticed that there was already a PR for this that got closed as stale. So I decided to just revive the PR #42524 by @weswigham
fixes #36981
fixes #31104