Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Improve constraints of conditional types applied to constrained type variables#56004

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
ahejlsberg merged 9 commits intomainfromfix30152
Nov 21, 2023

Conversation

@ahejlsberg
Copy link
Member

@ahejlsbergahejlsberg commentedOct 6, 2023
edited
Loading

With this PR we compute more accurate constraints for distributive conditional types applied to constrained type variables. For example:

typeIsArray<T>=Textendsany[] ?true :false;functionf1<Uextendsobject>(x:IsArray<U>){lett:true=x;// Errorletf:false=x;// Error, but previously wasn't}

Previously, we'd obtain the constraint ofIsArray<U> by applying the distributive conditional type to the constraint ofU, which resolves tofalse (becauseobject doesn't extendany[]). But really, it ought to beboolean (i.e.true | false) since clearly something constrained toobject both could or could not be an array.

A type variable represents any possible type within its constraint. So, given a type parameterT with the constraintC, the constraint ofT extends X ? A : B is

  • A whenC is known to always extendX,
  • B whenC is known to never extendX, or
  • A | B whenC possibly extendsX.

We previously didn't consider the third possibility. With this PR, we choose the third outcome whenC is not assignable toX, butX (or, ifX is a union type, some constituent ofX) is assignable toC.

Fixes#30152.

@typescript-bottypescript-bot added Author: Team For Uncommitted BugPR for untriaged, rejected, closed or missing bug labelsOct 6, 2023
@ahejlsberg
Copy link
MemberAuthor

@typescript-bot test top100
@typescript-bot user test this
@typescript-bot run dt
@typescript-bot perf test this faster

@typescript-bot
Copy link
Collaborator

typescript-bot commentedOct 6, 2023
edited
Loading

Heya@ahejlsberg, I've started to run the parallelized Definitely Typed test suite on this PR at2f5d9e9. You can monitor the buildhere.

Update:The results are in!

@typescript-bot
Copy link
Collaborator

typescript-bot commentedOct 6, 2023
edited
Loading

Heya@ahejlsberg, I've started to run the diff-based user code test suite on this PR at2f5d9e9. You can monitor the buildhere.

@typescript-bot
Copy link
Collaborator

typescript-bot commentedOct 6, 2023
edited
Loading

Heya@ahejlsberg, I've started to run the tsc-only perf test suite on this PR at2f5d9e9. You can monitor the buildhere.

Update:The results are in!

@typescript-bot
Copy link
Collaborator

typescript-bot commentedOct 6, 2023
edited
Loading

Heya@ahejlsberg, I've started to run the diff-based top-repos suite on this PR at2f5d9e9. You can monitor the buildhere.

Update:The results are in!

@typescript-bot
Copy link
Collaborator

@ahejlsberg
The results of the perf run you requested are in!

Here they are:

Compiler

Comparison Report - baseline..pr
MetricbaselineprDeltaBestWorstp-value
Angular - node (v18.15.0, x64)
Memory used295,077k (± 0.02%)295,077k (± 0.01%)~295,034k295,133kp=0.689 n=6
Parse Time2.63s (± 0.48%)2.63s (± 0.64%)~2.61s2.65sp=1.000 n=6
Bind Time0.84s (± 0.89%)0.84s (± 1.06%)~0.83s0.85sp=0.798 n=6
Check Time8.06s (± 0.20%)8.07s (± 0.21%)~8.04s8.09sp=0.217 n=6
Emit Time7.05s (± 0.66%)7.05s (± 0.37%)~7.02s7.10sp=0.805 n=6
Total Time18.58s (± 0.27%)18.59s (± 0.21%)~18.54s18.65sp=0.629 n=6
Compiler-Unions - node (v18.15.0, x64)
Memory used190,688k (± 0.01%)191,664k (± 1.24%)~190,674k196,504kp=0.378 n=6
Parse Time1.35s (± 0.38%)1.34s (± 0.61%)~1.33s1.35sp=0.523 n=6
Bind Time0.73s (± 0.00%)0.73s (± 0.00%)~0.73s0.73sp=1.000 n=6
Check Time9.20s (± 0.73%)9.20s (± 0.89%)~9.15s9.37sp=0.809 n=6
Emit Time2.63s (± 0.52%)2.60s (± 0.32%)-0.02s (- 0.82%)2.60s2.62sp=0.013 n=6
Total Time13.90s (± 0.46%)13.88s (± 0.58%)~13.83s14.04sp=0.463 n=6
Monaco - node (v18.15.0, x64)
Memory used347,295k (± 0.01%)347,297k (± 0.01%)~347,256k347,322kp=0.810 n=6
Parse Time2.46s (± 0.48%)2.47s (± 0.30%)~2.46s2.48sp=0.150 n=6
Bind Time0.94s (± 0.87%)0.94s (± 0.00%)~0.94s0.94sp=0.405 n=6
Check Time6.89s (± 0.30%)6.93s (± 0.42%)+0.04s (+ 0.61%)6.89s6.97sp=0.023 n=6
Emit Time4.03s (± 0.69%)4.02s (± 0.44%)~4.01s4.05sp=1.000 n=6
Total Time14.31s (± 0.20%)14.36s (± 0.27%)~14.30s14.39sp=0.052 n=6
TFS - node (v18.15.0, x64)
Memory used302,555k (± 0.01%)302,545k (± 0.00%)~302,535k302,556kp=0.687 n=6
Parse Time2.00s (± 0.58%)2.00s (± 1.07%)~1.97s2.03sp=0.870 n=6
Bind Time1.00s (± 1.04%)1.00s (± 0.41%)~1.00s1.01sp=0.528 n=6
Check Time6.25s (± 0.58%)6.26s (± 0.31%)~6.23s6.28sp=0.568 n=6
Emit Time3.57s (± 0.29%)3.56s (± 0.60%)~3.52s3.58sp=0.616 n=6
Total Time12.82s (± 0.23%)12.81s (± 0.33%)~12.74s12.86sp=0.871 n=6
material-ui - node (v18.15.0, x64)
Memory used470,530k (± 0.00%)568,506k (± 0.01%)🔻+97,977k (+20.82%)568,446k568,552kp=0.005 n=6
Parse Time2.57s (± 0.72%)2.58s (± 0.55%)~2.56s2.60sp=0.516 n=6
Bind Time0.99s (± 0.99%)0.99s (± 1.18%)~0.97s1.00sp=1.000 n=6
Check Time16.61s (± 0.59%)19.11s (± 0.66%)🔻+2.50s (+15.03%)18.94s19.29sp=0.005 n=6
Emit Time0.00s (± 0.00%)0.00s (± 0.00%)~0.00s0.00sp=1.000 n=6
Total Time20.18s (± 0.40%)22.68s (± 0.48%)🔻+2.50s (+12.40%)22.53s22.83sp=0.005 n=6
xstate - node (v18.15.0, x64)
Memory used512,583k (± 0.02%)511,800k (± 0.02%)-784k (- 0.15%)511,733k511,963kp=0.005 n=6
Parse Time3.27s (± 0.39%)3.27s (± 0.32%)~3.26s3.29sp=0.868 n=6
Bind Time1.55s (± 0.58%)1.55s (± 0.53%)~1.54s1.56sp=0.550 n=6
Check Time2.87s (± 0.19%)2.83s (± 0.65%)-0.04s (- 1.28%)2.81s2.86sp=0.008 n=6
Emit Time0.08s (± 0.00%)0.08s (± 0.00%)~0.08s0.08sp=1.000 n=6
Total Time7.76s (± 0.15%)7.72s (± 0.23%)-0.04s (- 0.54%)7.70s7.75sp=0.008 n=6
System info unknown
Hosts
  • node (v18.15.0, x64)
Scenarios
  • Angular - node (v18.15.0, x64)
  • Compiler-Unions - node (v18.15.0, x64)
  • Monaco - node (v18.15.0, x64)
  • TFS - node (v18.15.0, x64)
  • material-ui - node (v18.15.0, x64)
  • xstate - node (v18.15.0, x64)
BenchmarkNameIterations
Currentpr6
Baselinebaseline6

Developer Information:

Download Benchmarks

@typescript-bot
Copy link
Collaborator

@ahejlsberg Here are the results of running the top-repos suite comparingmain andrefs/pull/56004/merge:

Something interesting changed - please have a look.

Details

backstage/backstage

7 of 13 projects failed to build with the old tsc and were ignored

packages/cli/templates/default-react-plugin-package/tsconfig.json

react-hook-form/react-hook-form

2 of 3 projects failed to build with the old tsc and were ignored

tsconfig.json

vuejs/core

1 of 3 projects failed to build with the old tsc and were ignored

tsconfig.build.json

tsconfig.json

@typescript-bot
Copy link
Collaborator

Hey@ahejlsberg, the results of running the DT tests are ready.
There were interesting changes:

Branch only errors:

Package: reflexbox
Error:

Error: Errors in typescript@local for external dependencies:node_modules/@emotion/styled/types/base.d.ts(127,22): error TS2344: Type 'ForwardedProps' does not satisfy the constraint 'keyof PropsOf<C>'.  Type 'keyof ComponentProps<C> & string' is not assignable to type 'keyof PropsOf<C>'.    Type 'keyof ComponentProps<C> & string' is not assignable to type 'keyof ComponentProps<C> & keyof MergePropTypes<ComponentProps<C>, InferProps<WeakValidationMap<ComponentProps<C>> | undefined>> & keyof Defaultize<...> & keyof Defaultize<...>'.      Type 'ForwardedProps' is not assignable to type 'keyof ComponentProps<C> & keyof MergePropTypes<ComponentProps<C>, InferProps<WeakValidationMap<ComponentProps<C>> | undefined>> & keyof Defaultize<...> & keyof Defaultize<...>'.        Type 'keyof ComponentProps<C> & string' is not assignable to type 'keyof ComponentProps<C> & keyof MergePropTypes<ComponentProps<C>, InferProps<WeakValidationMap<ComponentProps<C>> | undefined>> & keyof Defaultize<...> & keyof Defaultize<...>'.          Type 'keyof ComponentProps<C> & string' is not assignable to type 'keyof MergePropTypes<ComponentProps<C>, InferProps<WeakValidationMap<ComponentProps<C>> | undefined>>'.            Type 'ForwardedProps' is not assignable to type 'keyof MergePropTypes<ComponentProps<C>, InferProps<WeakValidationMap<ComponentProps<C>> | undefined>>'.              Type 'keyof ComponentProps<C> & string' is not assignable to type 'keyof MergePropTypes<ComponentProps<C>, InferProps<WeakValidationMap<ComponentProps<C>> | undefined>>'.                Type 'keyof ComponentProps<C> & string' is not assignable to type 'keyof (IsExactlyAny<ComponentProps<C>> extends true ? InferProps<WeakValidationMap<ComponentProps<C>> | undefined> : string extends keyof ComponentProps<...> ? ComponentProps<...> : Pick<...> & ... 1 more ... & Pick<...>)'.                  Type 'ForwardedProps' is not assignable to type 'keyof (IsExactlyAny<ComponentProps<C>> extends true ? InferProps<WeakValidationMap<ComponentProps<C>> | undefined> : string extends keyof ComponentProps<...> ? ComponentProps<...> : Pick<...> & ... 1 more ... & Pick<...>)'.                    Type 'keyof ComponentProps<C> & string' is not assignable to type 'keyof (IsExactlyAny<ComponentProps<C>> extends true ? InferProps<WeakValidationMap<ComponentProps<C>> | undefined> : string extends keyof ComponentProps<...> ? ComponentProps<...> : Pick<...> & ... 1 more ... & Pick<...>)'.                      Type 'keyof ComponentProps<C> & string' is not assignable to type 'RequiredKeys<WeakValidationMap<ComponentProps<C>> | undefined> & keyof (string extends keyof ComponentProps<C> ? ComponentProps<...> : Pick<...> & ... 1 more ... & Pick<...>)'.                        Type 'ForwardedProps' is not assignable to type 'RequiredKeys<WeakValidationMap<ComponentProps<C>> | undefined> & keyof (string extends keyof ComponentProps<C> ? ComponentProps<...> : Pick<...> & ... 1 more ... & Pick<...>)'.                          Type 'keyof ComponentProps<C> & string' is not assignable to type 'RequiredKeys<WeakValidationMap<ComponentProps<C>> | undefined> & keyof (string extends keyof ComponentProps<C> ? ComponentProps<...> : Pick<...> & ... 1 more ... & Pick<...>)'.                            Type 'keyof ComponentProps<C> & string' is not assignable to type 'RequiredKeys<WeakValidationMap<ComponentProps<C>> | undefined>'.                              Type 'ForwardedProps' is not assignable to type 'RequiredKeys<WeakValidationMap<ComponentProps<C>> | undefined>'.                                Type 'keyof ComponentProps<C> & string' is not assignable to type 'never'.node_modules/@emotion/styled/types/base.d.ts(157,22): error TS2344: Type 'ForwardedProps' does not satisfy the constraint 'keyof PropsOf<C>'.  Type 'keyof ComponentProps<C> & string' is not assignable to type 'keyof PropsOf<C>'.    Type 'keyof ComponentProps<C> & string' is not assignable to type 'keyof ComponentProps<C> & keyof MergePropTypes<ComponentProps<C>, InferProps<WeakValidationMap<ComponentProps<C>> | undefined>> & keyof Defaultize<...> & keyof Defaultize<...> & keyof (C extends MemoExoticComponent<...> | LazyExoticComponent<...> ? ReactManagedAttributes<...> : ReactManagedAttributes<...>)'.      Type 'ForwardedProps' is not assignable to type 'keyof ComponentProps<C> & keyof MergePropTypes<ComponentProps<C>, InferProps<WeakValidationMap<ComponentProps<C>> | undefined>> & keyof Defaultize<...> & keyof Defaultize<...> & keyof (C extends MemoExoticComponent<...> | LazyExoticComponent<...> ? ReactManagedAttributes<...> : ReactManagedAttributes<...>)'.        Type 'keyof ComponentProps<C> & string' is not assignable to type 'keyof ComponentProps<C> & keyof MergePropTypes<ComponentProps<C>, InferProps<WeakValidationMap<ComponentProps<C>> | undefined>> & keyof Defaultize<...> & keyof Defaultize<...> & keyof (C extends MemoExoticComponent<...> | LazyExoticComponent<...> ? ReactManagedAttributes<...> : ReactManagedAttributes<...>)'.          Type 'keyof ComponentProps<C> & string' is not assignable to type 'keyof MergePropTypes<ComponentProps<C>, InferProps<WeakValidationMap<ComponentProps<C>> | undefined>>'.            Type 'ForwardedProps' is not assignable to type 'keyof MergePropTypes<ComponentProps<C>, InferProps<WeakValidationMap<ComponentProps<C>> | undefined>>'.              Type 'keyof ComponentProps<C> & string' is not assignable to type 'keyof MergePropTypes<ComponentProps<C>, InferProps<WeakValidationMap<ComponentProps<C>> | undefined>>'.                Type 'keyof ComponentProps<C> & string' is not assignable to type 'keyof (IsExactlyAny<ComponentProps<C>> extends true ? InferProps<WeakValidationMap<ComponentProps<C>> | undefined> : string extends keyof ComponentProps<...> ? ComponentProps<...> : Pick<...> & ... 1 more ... & Pick<...>)'.                  Type 'ForwardedProps' is not assignable to type 'keyof (IsExactlyAny<ComponentProps<C>> extends true ? InferProps<WeakValidationMap<ComponentProps<C>> | undefined> : string extends keyof ComponentProps<...> ? ComponentProps<...> : Pick<...> & ... 1 more ... & Pick<...>)'.                    Type 'keyof ComponentProps<C> & string' is not assignable to type 'keyof (IsExactlyAny<ComponentProps<C>> extends true ? InferProps<WeakValidationMap<ComponentProps<C>> | undefined> : string extends keyof ComponentProps<...> ? ComponentProps<...> : Pick<...> & ... 1 more ... & Pick<...>)'.                      Type 'keyof ComponentProps<C> & string' is not assignable to type 'RequiredKeys<WeakValidationMap<ComponentProps<C>> | undefined> & keyof (string extends keyof ComponentProps<C> ? ComponentProps<...> : Pick<...> & ... 1 more ... & Pick<...>)'.                        Type 'ForwardedProps' is not assignable to type 'RequiredKeys<WeakValidationMap<ComponentProps<C>> | undefined> & keyof (string extends keyof ComponentProps<C> ? ComponentProps<...> : Pick<...> & ... 1 more ... & Pick<...>)'.                          Type 'keyof ComponentProps<C> & string' is not assignable to type 'RequiredKeys<WeakValidationMap<ComponentProps<C>> | undefined> & keyof (string extends keyof ComponentProps<C> ? ComponentProps<...> : Pick<...> & ... 1 more ... & Pick<...>)'.                            Type 'keyof ComponentProps<C> & string' is not assignable to type 'RequiredKeys<WeakValidationMap<ComponentProps<C>> | undefined>'.                              Type 'ForwardedProps' is not assignable to type 'RequiredKeys<WeakValidationMap<ComponentProps<C>> | undefined>'.                                Type 'keyof ComponentProps<C> & string' is not assignable to type 'never'.    at testTypesVersion (/home/vsts/work/1/s/DefinitelyTyped-tools/packages/dtslint/dist/index.js:194:15)    at async runTests (/home/vsts/work/1/s/DefinitelyTyped-tools/packages/dtslint/dist/index.js:151:9)

Package: knex-cleaner
Error:

Error: Errors in typescript@local for external dependencies:node_modules/knex/types/index.d.ts(1240,50): error TS2344: Type 'ResolveTableType<TRecord, "base">' does not satisfy the constraint '{}'.  Type 'unknown' is not assignable to type '{}'.node_modules/knex/types/index.d.ts(1255,50): error TS2344: Type 'ResolveTableType<TRecord, "base">' does not satisfy the constraint '{}'.    at testTypesVersion (/home/vsts/work/1/s/DefinitelyTyped-tools/packages/dtslint/dist/index.js:194:15)    at async runTests (/home/vsts/work/1/s/DefinitelyTyped-tools/packages/dtslint/dist/index.js:151:9)

Package: mui-datatables
Error:

Error: Errors in typescript@local for external dependencies:node_modules/@emotion/styled/types/base.d.ts(127,22): error TS2344: Type 'ForwardedProps' does not satisfy the constraint 'keyof PropsOf<C>'.  Type 'keyof ComponentProps<C> & string' is not assignable to type 'keyof PropsOf<C>'.    Type 'keyof ComponentProps<C> & string' is not assignable to type 'keyof ComponentProps<C> & keyof MergePropTypes<ComponentProps<C>, InferProps<WeakValidationMap<ComponentProps<C>> | undefined>> & keyof Defaultize<...> & keyof Defaultize<...>'.      Type 'ForwardedProps' is not assignable to type 'keyof ComponentProps<C> & keyof MergePropTypes<ComponentProps<C>, InferProps<WeakValidationMap<ComponentProps<C>> | undefined>> & keyof Defaultize<...> & keyof Defaultize<...>'.        Type 'keyof ComponentProps<C> & string' is not assignable to type 'keyof ComponentProps<C> & keyof MergePropTypes<ComponentProps<C>, InferProps<WeakValidationMap<ComponentProps<C>> | undefined>> & keyof Defaultize<...> & keyof Defaultize<...>'.          Type 'keyof ComponentProps<C> & string' is not assignable to type 'keyof MergePropTypes<ComponentProps<C>, InferProps<WeakValidationMap<ComponentProps<C>> | undefined>>'.            Type 'ForwardedProps' is not assignable to type 'keyof MergePropTypes<ComponentProps<C>, InferProps<WeakValidationMap<ComponentProps<C>> | undefined>>'.              Type 'keyof ComponentProps<C> & string' is not assignable to type 'keyof MergePropTypes<ComponentProps<C>, InferProps<WeakValidationMap<ComponentProps<C>> | undefined>>'.                Type 'keyof ComponentProps<C> & string' is not assignable to type 'keyof (IsExactlyAny<ComponentProps<C>> extends true ? InferProps<WeakValidationMap<ComponentProps<C>> | undefined> : string extends keyof ComponentProps<...> ? ComponentProps<...> : Pick<...> & ... 1 more ... & Pick<...>)'.                  Type 'ForwardedProps' is not assignable to type 'keyof (IsExactlyAny<ComponentProps<C>> extends true ? InferProps<WeakValidationMap<ComponentProps<C>> | undefined> : string extends keyof ComponentProps<...> ? ComponentProps<...> : Pick<...> & ... 1 more ... & Pick<...>)'.                    Type 'keyof ComponentProps<C> & string' is not assignable to type 'keyof (IsExactlyAny<ComponentProps<C>> extends true ? InferProps<WeakValidationMap<ComponentProps<C>> | undefined> : string extends keyof ComponentProps<...> ? ComponentProps<...> : Pick<...> & ... 1 more ... & Pick<...>)'.                      Type 'keyof ComponentProps<C> & string' is not assignable to type 'RequiredKeys<WeakValidationMap<ComponentProps<C>> | undefined> & keyof (string extends keyof ComponentProps<C> ? ComponentProps<...> : Pick<...> & ... 1 more ... & Pick<...>)'.                        Type 'ForwardedProps' is not assignable to type 'RequiredKeys<WeakValidationMap<ComponentProps<C>> | undefined> & keyof (string extends keyof ComponentProps<C> ? ComponentProps<...> : Pick<...> & ... 1 more ... & Pick<...>)'.                          Type 'keyof ComponentProps<C> & string' is not assignable to type 'RequiredKeys<WeakValidationMap<ComponentProps<C>> | undefined> & keyof (string extends keyof ComponentProps<C> ? ComponentProps<...> : Pick<...> & ... 1 more ... & Pick<...>)'.                            Type 'keyof ComponentProps<C> & string' is not assignable to type 'RequiredKeys<WeakValidationMap<ComponentProps<C>> | undefined>'.                              Type 'ForwardedProps' is not assignable to type 'RequiredKeys<WeakValidationMap<ComponentProps<C>> | undefined>'.                                Type 'keyof ComponentProps<C> & string' is not assignable to type 'never'.node_modules/@emotion/styled/types/base.d.ts(157,22): error TS2344: Type 'ForwardedProps' does not satisfy the constraint 'keyof PropsOf<C>'.  Type 'keyof ComponentProps<C> & string' is not assignable to type 'keyof PropsOf<C>'.    Type 'keyof ComponentProps<C> & string' is not assignable to type 'keyof ComponentProps<C> & keyof MergePropTypes<ComponentProps<C>, InferProps<WeakValidationMap<ComponentProps<C>> | undefined>> & keyof Defaultize<...> & keyof Defaultize<...> & keyof (C extends MemoExoticComponent<...> | LazyExoticComponent<...> ? ReactManagedAttributes<...> : ReactManagedAttributes<...>)'.      Type 'ForwardedProps' is not assignable to type 'keyof ComponentProps<C> & keyof MergePropTypes<ComponentProps<C>, InferProps<WeakValidationMap<ComponentProps<C>> | undefined>> & keyof Defaultize<...> & keyof Defaultize<...> & keyof (C extends MemoExoticComponent<...> | LazyExoticComponent<...> ? ReactManagedAttributes<...> : ReactManagedAttributes<...>)'.        Type 'keyof ComponentProps<C> & string' is not assignable to type 'keyof ComponentProps<C> & keyof MergePropTypes<ComponentProps<C>, InferProps<WeakValidationMap<ComponentProps<C>> | undefined>> & keyof Defaultize<...> & keyof Defaultize<...> & keyof (C extends MemoExoticComponent<...> | LazyExoticComponent<...> ? ReactManagedAttributes<...> : ReactManagedAttributes<...>)'.          Type 'keyof ComponentProps<C> & string' is not assignable to type 'keyof MergePropTypes<ComponentProps<C>, InferProps<WeakValidationMap<ComponentProps<C>> | undefined>>'.            Type 'ForwardedProps' is not assignable to type 'keyof MergePropTypes<ComponentProps<C>, InferProps<WeakValidationMap<ComponentProps<C>> | undefined>>'.              Type 'keyof ComponentProps<C> & string' is not assignable to type 'keyof MergePropTypes<ComponentProps<C>, InferProps<WeakValidationMap<ComponentProps<C>> | undefined>>'.                Type 'keyof ComponentProps<C> & string' is not assignable to type 'keyof (IsExactlyAny<ComponentProps<C>> extends true ? InferProps<WeakValidationMap<ComponentProps<C>> | undefined> : string extends keyof ComponentProps<...> ? ComponentProps<...> : Pick<...> & ... 1 more ... & Pick<...>)'.                  Type 'ForwardedProps' is not assignable to type 'keyof (IsExactlyAny<ComponentProps<C>> extends true ? InferProps<WeakValidationMap<ComponentProps<C>> | undefined> : string extends keyof ComponentProps<...> ? ComponentProps<...> : Pick<...> & ... 1 more ... & Pick<...>)'.                    Type 'keyof ComponentProps<C> & string' is not assignable to type 'keyof (IsExactlyAny<ComponentProps<C>> extends true ? InferProps<WeakValidationMap<ComponentProps<C>> | undefined> : string extends keyof ComponentProps<...> ? ComponentProps<...> : Pick<...> & ... 1 more ... & Pick<...>)'.                      Type 'keyof ComponentProps<C> & string' is not assignable to type 'RequiredKeys<WeakValidationMap<ComponentProps<C>> | undefined> & keyof (string extends keyof ComponentProps<C> ? ComponentProps<...> : Pick<...> & ... 1 more ... & Pick<...>)'.                        Type 'ForwardedProps' is not assignable to type 'RequiredKeys<WeakValidationMap<ComponentProps<C>> | undefined> & keyof (string extends keyof ComponentProps<C> ? ComponentProps<...> : Pick<...> & ... 1 more ... & Pick<...>)'.                          Type 'keyof ComponentProps<C> & string' is not assignable to type 'RequiredKeys<WeakValidationMap<ComponentProps<C>> | undefined> & keyof (string extends keyof ComponentProps<C> ? ComponentProps<...> : Pick<...> & ... 1 more ... & Pick<...>)'.                            Type 'keyof ComponentProps<C> & string' is not assignable to type 'RequiredKeys<WeakValidationMap<ComponentProps<C>> | undefined>'.                              Type 'ForwardedProps' is not assignable to type 'RequiredKeys<WeakValidationMap<ComponentProps<C>> | undefined>'.                                Type 'keyof ComponentProps<C> & string' is not assignable to type 'never'.node_modules/@mui/styled-engine/index.d.ts(160,22): error TS2344: Type 'ForwardedProps' does not satisfy the constraint 'keyof PropsOf<C>'.  Type 'keyof ComponentProps<C>' is not assignable to type 'keyof PropsOf<C>'.    Type 'string | number | symbol' is not assignable to type 'keyof PropsOf<C>'.      Type 'string' is not assignable to type 'keyof PropsOf<C>'.        Type 'string' is not assignable to type 'keyof ComponentProps<C> & keyof MergePropTypes<ComponentProps<C>, InferProps<WeakValidationMap<ComponentProps<C>> | undefined>> & keyof Defaultize<...> & keyof Defaultize<...>'.          Type 'keyof ComponentProps<C>' is not assignable to type 'keyof ComponentProps<C> & keyof MergePropTypes<ComponentProps<C>, InferProps<WeakValidationMap<ComponentProps<C>> | undefined>> & keyof Defaultize<...> & keyof Defaultize<...>'.            Type 'ForwardedProps' is not assignable to type 'keyof ComponentProps<C> & keyof MergePropTypes<ComponentProps<C>, InferProps<WeakValidationMap<ComponentProps<C>> | undefined>> & keyof Defaultize<...> & keyof Defaultize<...>'.              Type 'keyof ComponentProps<C>' is not assignable to type 'keyof ComponentProps<C> & keyof MergePropTypes<ComponentProps<C>, InferProps<WeakValidationMap<ComponentProps<C>> | undefined>> & keyof Defaultize<...> & keyof Defaultize<...>'.                Type 'string | number | symbol' is not assignable to type 'keyof ComponentProps<C> & keyof MergePropTypes<ComponentProps<C>, InferProps<WeakValidationMap<ComponentProps<C>> | undefined>> & keyof Defaultize<...> & keyof Defaultize<...>'.                  Type 'string' is not assignable to type 'keyof ComponentProps<C> & keyof MergePropTypes<ComponentProps<C>, InferProps<WeakValidationMap<ComponentProps<C>> | undefined>> & keyof Defaultize<...> & keyof Defaultize<...>'.                    Type 'string' is not assignable to type 'keyof ComponentProps<C>'.                      Type 'keyof ComponentProps<C>' is not assignable to type 'keyof MergePropTypes<ComponentProps<C>, InferProps<WeakValidationMap<ComponentProps<C>> | undefined>>'.                        Type 'ForwardedProps' is not assignable to type 'keyof MergePropTypes<ComponentProps<C>, InferProps<WeakValidationMap<ComponentProps<C>> | undefined>>'.                          Type 'keyof ComponentProps<C>' is not assignable to type 'keyof MergePropTypes<ComponentProps<C>, InferProps<WeakValidationMap<ComponentProps<C>> | undefined>>'.                            Type 'string | number | symbol' is not assignable to type 'keyof MergePropTypes<ComponentProps<C>, InferProps<WeakValidationMap<ComponentProps<C>> | undefined>>'.                              Type 'string' is not assignable to type 'keyof MergePropTypes<ComponentProps<C>, InferProps<WeakValidationMap<ComponentProps<C>> | undefined>>'.                                Type 'string' is not assignable to type 'keyof (IsExactlyAny<ComponentProps<C>> extends true ? InferProps<WeakValidationMap<ComponentProps<C>> | undefined> : string extends keyof ComponentProps<...> ? ComponentProps<...> : Pick<...> & ... 1 more ... & Pick<...>)'.                                  Type 'keyof ComponentProps<C>' is not assignable to type 'keyof (IsExactlyAny<ComponentProps<C>> extends true ? InferProps<WeakValidationMap<ComponentProps<C>> | undefined> : string extends keyof ComponentProps<...> ? ComponentProps<...> : Pick<...> & ... 1 more ... & Pick<...>)'.                                    Type 'ForwardedProps' is not assignable to type 'keyof (IsExactlyAny<ComponentProps<C>> extends true ? InferProps<WeakValidationMap<ComponentProps<C>> | undefined> : string extends keyof ComponentProps<...> ? ComponentProps<...> : Pick<...> & ... 1 more ... & Pick<...>)'.                                      Type 'keyof ComponentProps<C>' is not assignable to type 'keyof (IsExactlyAny<ComponentProps<C>> extends true ? InferProps<WeakValidationMap<ComponentProps<C>> | undefined> : string extends keyof ComponentProps<...> ? ComponentProps<...> : Pick<...> & ... 1 more ... & Pick<...>)'.                                        Type 'string | number | symbol' is not assignable to type 'keyof (IsExactlyAny<ComponentProps<C>> extends true ? InferProps<WeakValidationMap<ComponentProps<C>> | undefined> : string extends keyof ComponentProps<...> ? ComponentProps<...> : Pick<...> & ... 1 more ... & Pick<...>)'.                                          Type 'string' is not assignable to type 'keyof (IsExactlyAny<ComponentProps<C>> extends true ? InferProps<WeakValidationMap<ComponentProps<C>> | undefined> : string extends keyof ComponentProps<...> ? ComponentProps<...> : Pick<...> & ... 1 more ... & Pick<...>)'.                                            Type 'string' is not assignable to type 'RequiredKeys<WeakValidationMap<ComponentProps<C>> | undefined> & keyof (string extends keyof ComponentProps<C> ? ComponentProps<...> : Pick<...> & ... 1 more ... & Pick<...>)'.                                              Type 'keyof ComponentProps<C>' is not assignable to type 'RequiredKeys<WeakValidationMap<ComponentProps<C>> | undefined> & keyof (string extends keyof ComponentProps<C> ? ComponentProps<...> : Pick<...> & ... 1 more ... & Pick<...>)'.                                                Type 'ForwardedProps' is not assignable to type 'RequiredKeys<WeakValidationMap<ComponentProps<C>> | undefined> & keyof (string extends keyof ComponentProps<C> ? ComponentProps<...> : Pick<...> & ... 1 more ... & Pick<...>)'.                                                  Type 'keyof ComponentProps<C>' is not assignable to type 'RequiredKeys<WeakValidationMap<ComponentProps<C>> | undefined> & keyof (string extends keyof ComponentProps<C> ? ComponentProps<...> : Pick<...> & ... 1 more ... & Pick<...>)'.                                                    Type 'string | number | symbol' is not assignable to type 'RequiredKeys<WeakValidationMap<ComponentProps<C>> | undefined> & keyof (string extends keyof ComponentProps<C> ? ComponentProps<...> : Pick<...> & ... 1 more ... & Pick<...>)'.                                                      Type 'string' is not assignable to type 'RequiredKeys<WeakValidationMap<ComponentProps<C>> | undefined> & keyof (string extends keyof ComponentProps<C> ? ComponentProps<...> : Pick<...> & ... 1 more ... & Pick<...>)'.                                                        Type 'string' is not assignable to type 'RequiredKeys<WeakValidationMap<ComponentProps<C>> | undefined>'.                                                          Type 'keyof ComponentProps<C>' is not assignable to type 'RequiredKeys<WeakValidationMap<ComponentProps<C>> | undefined>'.                                                            Type 'ForwardedProps' is not assignable to type 'RequiredKeys<WeakValidationMap<ComponentProps<C>> | undefined>'.                                                              Type 'keyof ComponentProps<C>' is not assignable to type 'never'.                                                                Type 'string | number | symbol' is not assignable to type 'never'.                                                                  Type 'string' is not assignable to type 'never'.    at testTypesVersion (/home/vsts/work/1/s/DefinitelyTyped-tools/packages/dtslint/dist/index.js:194:15)    at async runTests (/home/vsts/work/1/s/DefinitelyTyped-tools/packages/dtslint/dist/index.js:151:9)

Package: knex-db-manager
Error:

Error: Errors in typescript@local for external dependencies:node_modules/knex/types/index.d.ts(1091,50): error TS2344: Type 'ResolveTableType<TRecord, "base">' does not satisfy the constraint '{}'.  Type 'unknown' is not assignable to type '{}'.node_modules/knex/types/index.d.ts(1103,50): error TS2344: Type 'ResolveTableType<TRecord, "base">' does not satisfy the constraint '{}'.    at testTypesVersion (/home/vsts/work/1/s/DefinitelyTyped-tools/packages/dtslint/dist/index.js:194:15)    at async runTests (/home/vsts/work/1/s/DefinitelyTyped-tools/packages/dtslint/dist/index.js:151:9)

You can check the log here.

@gabritto
Copy link
Member

@typescript-bot pack this

@typescript-bot
Copy link
Collaborator

typescript-bot commentedOct 6, 2023
edited
Loading

Heya@gabritto, I've started to run the tarball bundle task on this PR at2f5d9e9. You can monitor the buildhere.

@typescript-bot
Copy link
Collaborator

typescript-bot commentedOct 6, 2023
edited
Loading

Hey@gabritto, I've packed this intoan installable tgz. You can install it for testing by referencing it in yourpackage.json like so:

{    "devDependencies": {        "typescript": "https://typescript.visualstudio.com/cf7ac146-d525-443c-b23c-0d58337efebc/_apis/build/builds/158126/artifacts?artifactName=tgz&fileId=C312C2036DEE5998F78828DF563EFC75917CF2508AF2CDEC50D916C993783F9502&fileName=/typescript-5.3.0-insiders.20231006.tgz"    }}

and then runningnpm install.


There is also a playgroundfor this build and annpm module you can use via"typescript": "npm:@typescript-deploys/pr-build@5.3.0-pr-56004-10".;

@ahejlsberg
Copy link
MemberAuthor

@typescript-bot test top100
@typescript-bot user test this
@typescript-bot run dt
@typescript-bot perf test this faster

@typescript-bot
Copy link
Collaborator

typescript-bot commentedOct 6, 2023
edited
Loading

Heya@ahejlsberg, I've started to run the diff-based user code test suite on this PR atc7613d6. You can monitor the buildhere.

Update:The results are in!

@typescript-bot
Copy link
Collaborator

typescript-bot commentedOct 6, 2023
edited
Loading

Heya@ahejlsberg, I've started to run the tsc-only perf test suite on this PR atc7613d6. You can monitor the buildhere.

Update:The results are in!

@typescript-bot
Copy link
Collaborator

typescript-bot commentedOct 6, 2023
edited
Loading

Heya@ahejlsberg, I've started to run the parallelized Definitely Typed test suite on this PR atc7613d6. You can monitor the buildhere.

Update:The results are in!

@typescript-bot
Copy link
Collaborator

typescript-bot commentedOct 6, 2023
edited
Loading

Heya@ahejlsberg, I've started to run the diff-based top-repos suite on this PR atc7613d6. You can monitor the buildhere.

Update:The results are in!

@typescript-bot
Copy link
Collaborator

@ahejlsberg
The results of the perf run you requested are in!

Here they are:

Compiler

Comparison Report - baseline..pr
MetricbaselineprDeltaBestWorstp-value
Angular - node (v18.15.0, x64)
Memory used295,069k (± 0.01%)295,049k (± 0.02%)~294,949k295,095kp=0.378 n=6
Parse Time2.64s (± 0.48%)2.63s (± 0.40%)~2.62s2.65sp=0.456 n=6
Bind Time0.84s (± 0.99%)0.85s (± 0.96%)~0.83s0.85sp=0.673 n=6
Check Time8.05s (± 0.54%)8.06s (± 0.31%)~8.02s8.10sp=0.568 n=6
Emit Time7.05s (± 0.56%)7.05s (± 0.20%)~7.03s7.07sp=0.366 n=6
Total Time18.59s (± 0.25%)18.59s (± 0.19%)~18.54s18.65sp=0.936 n=6
Compiler-Unions - node (v18.15.0, x64)
Memory used194,451k (± 1.26%)191,117k (± 0.54%)~190,663k193,214kp=0.065 n=6
Parse Time1.34s (± 0.61%)1.34s (± 1.31%)~1.31s1.35sp=0.730 n=6
Bind Time0.73s (± 0.00%)0.73s (± 0.00%)~0.73s0.73sp=1.000 n=6
Check Time9.21s (± 1.04%)9.21s (± 0.75%)~9.13s9.32sp=1.000 n=6
Emit Time2.63s (± 0.81%)2.60s (± 0.63%)~2.59s2.63sp=0.061 n=6
Total Time13.91s (± 0.79%)13.88s (± 0.50%)~13.82s14.01sp=0.573 n=6
Monaco - node (v18.15.0, x64)
Memory used347,311k (± 0.01%)347,286k (± 0.01%)~347,265k347,312kp=0.093 n=6
Parse Time2.46s (± 0.33%)2.46s (± 0.42%)~2.44s2.47sp=0.932 n=6
Bind Time0.94s (± 0.43%)0.94s (± 0.67%)~0.93s0.95sp=0.673 n=6
Check Time6.94s (± 0.51%)6.90s (± 0.42%)~6.87s6.94sp=0.089 n=6
Emit Time4.03s (± 0.41%)4.03s (± 0.26%)~4.01s4.04sp=1.000 n=6
Total Time14.37s (± 0.25%)14.33s (± 0.16%)~14.30s14.36sp=0.075 n=6
TFS - node (v18.15.0, x64)
Memory used302,551k (± 0.00%)302,542k (± 0.00%)~302,524k302,561kp=0.336 n=6
Parse Time1.99s (± 1.00%)2.00s (± 1.08%)~1.98s2.03sp=0.328 n=6
Bind Time1.00s (± 1.03%)1.00s (± 0.75%)~0.99s1.01sp=0.931 n=6
Check Time6.24s (± 0.29%)6.24s (± 0.34%)~6.21s6.26sp=0.935 n=6
Emit Time3.57s (± 0.34%)3.57s (± 0.41%)~3.55s3.59sp=0.564 n=6
Total Time12.80s (± 0.29%)12.82s (± 0.24%)~12.78s12.86sp=0.571 n=6
material-ui - node (v18.15.0, x64)
Memory used470,502k (± 0.00%)470,551k (± 0.00%)+49k (+ 0.01%)470,528k470,580kp=0.005 n=6
Parse Time2.57s (± 0.16%)2.58s (± 0.68%)~2.55s2.60sp=0.246 n=6
Bind Time1.00s (± 0.63%)0.99s (± 0.52%)~0.99s1.00sp=0.091 n=6
Check Time16.60s (± 0.47%)16.73s (± 0.20%)+0.13s (+ 0.76%)16.70s16.78sp=0.016 n=6
Emit Time0.00s (± 0.00%)0.00s (± 0.00%)~0.00s0.00sp=1.000 n=6
Total Time20.17s (± 0.36%)20.30s (± 0.20%)+0.13s (+ 0.64%)20.24s20.36sp=0.010 n=6
xstate - node (v18.15.0, x64)
Memory used512,602k (± 0.02%)511,778k (± 0.01%)-824k (- 0.16%)511,714k511,836kp=0.005 n=6
Parse Time3.27s (± 0.42%)3.28s (± 0.25%)~3.27s3.29sp=0.183 n=6
Bind Time1.55s (± 0.53%)1.55s (± 0.26%)~1.54s1.55sp=0.206 n=6
Check Time2.86s (± 1.05%)2.81s (± 0.61%)-0.05s (- 1.92%)2.78s2.83sp=0.005 n=6
Emit Time0.08s (± 7.90%)0.08s (± 0.00%)~0.08s0.08sp=1.000 n=6
Total Time7.76s (± 0.52%)7.70s (± 0.18%)-0.05s (- 0.71%)7.69s7.73sp=0.009 n=6
System info unknown
Hosts
  • node (v18.15.0, x64)
Scenarios
  • Angular - node (v18.15.0, x64)
  • Compiler-Unions - node (v18.15.0, x64)
  • Monaco - node (v18.15.0, x64)
  • TFS - node (v18.15.0, x64)
  • material-ui - node (v18.15.0, x64)
  • xstate - node (v18.15.0, x64)
BenchmarkNameIterations
Currentpr6
Baselinebaseline6

Developer Information:

Download Benchmarks

@typescript-bot
Copy link
Collaborator

@ahejlsberg Here are the results of running the user test suite comparingmain andrefs/pull/56004/merge:

There were infrastructure failures potentially unrelated to your change:

  • 3 instances of "Package install failed"
  • 1 instance of "Unknown failure"

Otherwise...

Everything looks good!

@ahejlsberg
Copy link
MemberAuthor

Latest commit changes checking for the "possibly extends" case to use a reverse assignability check. This check is not quite as permissible as a comparability check, meaning we'll less often hit the "possibly extends" case where the constraint is a union. Still, since constraint types are typically close-to-top types (likeobject or{}), it isn't likely to matter. And, certainly, performance with the reverse assignability test is much more acceptable.

@ahejlsbergahejlsberg added this to theTypeScript 5.4.0 milestoneOct 6, 2023
@ahejlsberg
Copy link
MemberAuthor

@MichaelMitchell-at That was an earlier copy of the PR. It works witha current build.

@MichaelMitchell-at
Copy link
Contributor

I tried the current build in our code base and ran into a couple of errors that I'm having trouble creating a minimal reproduction that I can share. In general they seem to arise when generics are involved together with complex conditional types. I wonder if I'm having trouble producing a minimal repro because in the actual code we're hitting one of the depth limits that exists in the type checker.

Unrelated, but just mentioning while I have your attention with the hope y'all will keep in mind, is on nightly I'm encountering a newThe inferred type of this node exceeds the maximum length the compiler will serialize error. It's not really actionable on our side; the object is created by composing a bunch of schema objects from our in-houseZod-like library. One of the reasons to use the schema library is to avoid needing to write out the type by hand. It would probably only help us temporarily if the max length were increased; A more long-term approach might be some ability to give users more control over when type aliases are used/expanded in types when serialized/displayed.

ackvf reacted with thumbs up emoji

@voxpelli
Copy link

As an FYI in case anyone follows this issue, it turned out that this caused a regression intype-fest and I'm still debugging why and/or how to fix, but want to mention here in the meanwhile, might file an issue later:sindresorhus/type-fest#784

voxpelli added a commit to sindresorhus/type-fest that referenced this pull requestJan 29, 2024
After the change inmicrosoft/TypeScript#56004 the `PickRestType` was causing some types to be considered theoretically infinite in their recursion.I can't wrap my mind around exactly why right now, but I can see how `PickRestType` on a crazy long tuple will cause a very deep recursion, so I decided to simply cap its recursion and return `unknown[]` if it goes past that point and that solved the errors.Side effects:- In practice: rarely any I believe- In theory: some merged types will regress to `unknown[]` in TypeScript versions older than 5.4Considerations:Is the `DepthTracker extends Array<true> = []` + `PickRestTypeMaxDepth extends DepthTracker['length']` a good way to track depth? I know I have done a depth check previous times but can't remember what solution I picked then.Fixes#784
@acutmoreacutmore mentioned this pull requestFeb 21, 2024
1 task
Haroenv added a commit to algolia/instantsearch that referenced this pull requestJun 20, 2024
I can't manage to reproduce this locally, even if i update everything to 5.4.5, but in a fresh Next.js example (likehttps://codesandbox.io/s/47fy7c) `hitsPerPage` isn't accepted to Configure (because PlainSearchParameters is any)This is I believe linked tomicrosoft/TypeScript#56004, maybe also tosindresorhus/type-fest#846 (although the case seems different).Essentially before this change the types like `ClientLiteV5` were evaluated to `any` instead of `unknown`, poisoning the entire type and turning everything into any.The solution is to first check if `typeof AlgoliaSearchLite` is any, and if it is any we don't even evaluate the rest of teh type. Of course if it isn't any it works correctly for v5 still.Again, unfortunately this isn't reproducible in this repo, even when every typescript version is updated to 5.4.5, but at least the error will be fixedfixes#5989
Haroenv added a commit to algolia/instantsearch that referenced this pull requestJun 20, 2024
)I can't manage to reproduce this locally, even if i update everything to 5.4.5, but in a fresh Next.js example (likehttps://codesandbox.io/s/47fy7c) `hitsPerPage` isn't accepted to Configure (because PlainSearchParameters is any)This is I believe linked tomicrosoft/TypeScript#56004, maybe also tosindresorhus/type-fest#846 (although the case seems different).Essentially before this change the types like `ClientLiteV5` were evaluated to `any` instead of `unknown`, poisoning the entire type and turning everything into any.The solution is to first check if `typeof AlgoliaSearchLite` is any, and if it is any we don't even evaluate the rest of teh type. Of course if it isn't any it works correctly for v5 still.Again, unfortunately this isn't reproducible in this repo, even when every typescript version is updated to 5.4.5, but at least the error will be fixedfixes#5989
@microsoftmicrosoft locked asresolvedand limited conversation to collaboratorsOct 16, 2025
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.

Reviewers

@weswighamweswighamweswigham approved these changes

@DanielRosenwasserDanielRosenwasserAwaiting requested review from DanielRosenwasser

@RyanCavanaughRyanCavanaughAwaiting requested review from RyanCavanaugh

Assignees

@ahejlsbergahejlsberg

Labels

Author: TeamFor Milestone BugPRs that fix a bug with a specific milestone

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Conditional types are incorrectly narrowed

7 participants

@ahejlsberg@typescript-bot@gabritto@MichaelMitchell-at@voxpelli@weswigham

[8]ページ先頭

©2009-2025 Movatter.jp