Repository navigation
[NewErrors] 4.8.0-dev.20220609 vs 4.7.3 #49461
Copy link
Copy link
Closed
Labels
DiscussionIssues which may not have code impactIssues which may not have code impact
Description
The following errors were reported by 4.8.0-dev.20220609, but not by 4.7.3
Pipeline that generated this bug
File that generated the pipeline
kamranahmedse/developer-roadmap
tsconfig.json
error TS2344: Type 'K' does not satisfy the constraint 'Record<string, any>'.- file:///mnt/ts_downloads/developer-roadmap/node_modules/@chakra-ui/descendant/src/use-descendant.ts#L11
- file:///mnt/ts_downloads/developer-roadmap/node_modules/@chakra-ui/descendant/src/use-descendant.ts#L87
- file:///mnt/ts_downloads/developer-roadmap/node_modules/@chakra-ui/descendant/src/use-descendant.ts#L91
coder/code-server
7 of 57 projects failed to build with the old tsc
src/tsconfig.monaco.json
error TS2322: Type '(_target: T, propKey: PropertyKey) => unknown' is not assignable to type '(target: object, p: string | symbol, receiver: any) => any'.
src/tsconfig.tsec.json
error TS2322: Type '(_target: T, propKey: PropertyKey) => unknown' is not assignable to type '(target: object, p: string | symbol, receiver: any) => any'.error TS2322: Type 'T' is not assignable to type 'RemoteServiceStub<T>'.error TS2409: Return type of constructor signature must be assignable to the instance type of the class.
microsoft/playwright
4 of 9 projects failed to build with the old tsc
packages/html-reporter/tsconfig.json
error TS2344: Type 'T' does not satisfy the constraint 'Channel'.
vercel/hyper
2 of 3 projects failed to build with the old tsc
tsconfig.json
error TS2344: Type 'BaseType' does not satisfy the constraint 'Record<string | number, any>'.- file:///mnt/ts_downloads/hyper/app/node_modules/type-fest/ts41/get.d.ts#L93 in app/tsconfig.json
- file:///mnt/ts_downloads/hyper/app/node_modules/type-fest/ts41/get.d.ts#L94 in app/tsconfig.json
error TS2344: Type 'T' does not satisfy the constraint 'Record<string, any>'.- file:///mnt/ts_downloads/hyper/app/node_modules/conf/dist/source/types.d.ts#L201 in app/tsconfig.json
react-hook-form/react-hook-form
2 of 3 projects failed to build with the old tsc
tsconfig.json
error TS2344: Type 'TFieldValues' does not satisfy the constraint 'FieldValues'.- src/tests/controller.test.tsx#L21
- src/logic/getResolverOptions.ts#L27
- src/types/fieldArray.ts#L99
- src/types/fieldArray.ts#L99
- src/types/fieldArray.ts#L102
- src/types/fieldArray.ts#L103
- src/types/fieldArray.ts#L130
- src/types/fieldArray.ts#L130
- src/types/fieldArray.ts#L133
- src/types/fieldArray.ts#L134
- src/types/fieldArray.ts#L183
- src/types/fieldArray.ts#L183
- src/types/fieldArray.ts#L187
- src/types/fieldArray.ts#L188
- src/types/fieldArray.ts#L214
- src/types/fieldArray.ts#L214
- src/types/fieldArray.ts#L217
- src/types/fieldArray.ts#L240
- src/types/fieldArray.ts#L240
- src/types/fieldArray.ts#L243
- src/types/fieldArray.ts#L244
- src/types/form.ts#L117
- src/types/form.ts#L121
- src/types/form.ts#L125
- src/types/form.ts#L140
- src/types/form.ts#L706
- src/types/form.ts#L706
- src/types/form.ts#L710
- src/types/form.ts#L757
- src/types/form.ts#L785
- src/types/form.ts#L788
- src/types/form.ts#L789
- src/types/form.ts#L790
- src/types/resolvers.ts#L22
- src/useWatch.ts#L147
error TS2344: Type 'T' does not satisfy the constraint 'FieldValues'.error TS2322: Type 'Control<T, any>' is not assignable to type 'Control<FieldValues, any>'.error TS2345: Argument of type 'U' is not assignable to parameter of type 'Partial<{ shouldValidate: boolean; shouldDirty: boolean; shouldTouch: boolean; }> | undefined'.error TS2533: Object is possibly 'null' or 'undefined'.
typeorm/typeorm
tsconfig.json
error TS2344: Type 'Entity' does not satisfy the constraint 'ObjectLiteral'.error TS2345: Argument of type 'DeepPartial<Entity>' is not assignable to parameter of type 'ObjectLiteral'.error TS2345: Argument of type 'T | T[]' is not assignable to parameter of type 'ObjectLiteral | ObjectLiteral[]'.error TS2345: Argument of type 'Entity | Entity[]' is not assignable to parameter of type 'ObjectLiteral | ObjectLiteral[]'.error TS2345: Argument of type 'EntityTarget<Entity>' is not assignable to parameter of type 'EntityTarget<ObjectLiteral>'.error TS2322: Type 'MongoRepository<ObjectLiteral>' is not assignable to type 'Repository<Entity>'.error TS2345: Argument of type 'Entity[]' is not assignable to parameter of type 'ObjectLiteral[]'.error TS2345: Argument of type 'E1 | E1[]' is not assignable to parameter of type 'ObjectLiteral | ObjectLiteral[]'.error TS2345: Argument of type 'Entity' is not assignable to parameter of type 'ObjectLiteral | undefined'.error TS2322: Type 'Entity[]' is not assignable to type 'ObjectLiteral[]'.error TS2345: Argument of type 'T' is not assignable to parameter of type 'ObjectLiteral'.error TS2344: Type 'T' does not satisfy the constraint 'ObjectLiteral'.error TS2345: Argument of type 'Entity' is not assignable to parameter of type 'ObjectLiteral'.error TS2769: No overload matches this call.error TS2322: Type 'Repository<ObjectLiteral>' is not assignable to type 'Repository<T>'.
mobxjs/mobx
7 of 9 projects failed to build with the old tsc
packages/mobx/tsconfig.json
error TS2322: Type 'IIsObservableObject & Object' is not assignable to type 'T'.error TS2345: Argument of type 'T' is not assignable to parameter of type 'Object'.
palantir/blueprint
13 of 27 projects failed to build with the old tsc
packages/datetime/src/tsconfig.json
error TS2339: Property 'className' does not exist on type '{}'.error TS2339: Property 'popoverClassName' does not exist on type '{}'.error TS2339: Property 'onClose' does not exist on type '{}'.
packages/select/src/tsconfig.json
error TS2339: Property 'fill' does not exist on type '{}'.error TS2339: Property 'inputProps' does not exist on type '{}'.error TS2339: Property 'className' does not exist on type '{}'.error TS2339: Property 'popoverClassName' does not exist on type '{}'.error TS2339: Property 'modifiers' does not exist on type '{}'.error TS7006: Parameter 'data' implicitly has an 'any' type.error TS2339: Property 'usePortal' does not exist on type '{}'.error TS2339: Property 'wrapperTagName' does not exist on type '{}'.
apollographql/apollo-client
tsconfig.json
error TS2345: Argument of type '{ store: EntityStore; rootId: string; config: InMemoryCacheConfig; previousResult?: any; optimistic: boolean; returnPartialData?: boolean | undefined; canonizeResults?: boolean | undefined; query: DocumentNode | TypedDocumentNode<...>; variables?: TVariables | undefined; id?: string | undefined; }' is not assignable to parameter of type 'DiffQueryAgainstStoreOptions'.error TS2345: Argument of type 'SubscriptionOptions<TVariables, T>' is not assignable to parameter of type 'SubscriptionOptions<OperationVariables, any>'.error TS2322: Type 'TSubscriptionVariables | undefined' is not assignable to type 'OperationVariables | undefined'.error TS2345: Argument of type 'TVariables' is not assignable to parameter of type 'OperationVariables | undefined'.error TS2345: Argument of type 'TVariables | undefined' is not assignable to parameter of type 'OperationVariables | undefined'.error TS2322: Type 'ObservableQuery<T, TVariables>' is not assignable to type 'ObservableQuery<any, OperationVariables>'.error TS2322: Type 'TVariables | undefined' is not assignable to type 'Record<string, any> | undefined'.error TS2345: Argument of type 'TVars | undefined' is not assignable to parameter of type 'OperationVariables | undefined'.error TS2345: Argument of type 'Pick<WatchQueryOptions<TVars, TData>, "variables" | "context" | "fetchPolicy" | "errorPolicy">' is not assignable to parameter of type 'Pick<WatchQueryOptions<OperationVariables, any>, "variables" | "fetchPolicy" | "errorPolicy">'.error TS2345: Argument of type 'TVars | (undefined & TVars)' is not assignable to parameter of type 'OperationVariables | undefined'.error TS2345: Argument of type '(variables: TVars) => ConcastSourcesIterable<ApolloQueryResult<TData>>' is not assignable to parameter of type '(value: { [x: string]: any; }) => ConcastSourcesIterable<ApolloQueryResult<TData>> | PromiseLike<ConcastSourcesIterable<ApolloQueryResult<TData>>>'.error TS2345: Argument of type 'WatchQueryOptions<TVars, TData>' is not assignable to parameter of type 'WatchQueryOptions<OperationVariables, any>'.error TS2322: Type 'TVars | undefined' is not assignable to type 'Record<string, any> | undefined'.error TS2345: Argument of type 'TVars | undefined' is not assignable to parameter of type 'Record<string, any> | undefined'.error TS2345: Argument of type 'OperationOption<TProps, TData, TGraphQLVariables, TChildProps, DefaultContext, ApolloCache<any>>' is not assignable to parameter of type 'OperationOption<TProps, Record<string, any>, TGraphQLVariables, TChildProps, DefaultContext, ApolloCache<any>>'.error TS2322: Type '(mutate: MutationFunction<TData, TGraphQLVariables>, { data, ...r }: MutationResult<TData>) => JSX.Element' is not assignable to type '(mutateFunction: MutationFunction<any, OperationVariables, DefaultContext, ApolloCache<any>>, result: MutationResult<...>) => Element | null'.error TS2322: Type 'TProps & TChildProps' is not assignable to type 'IntrinsicAttributes & TProps & TChildProps & { children?: ReactNode; }'.error TS2322: Type 'TChildProps' is not assignable to type '{ [x: string]: any; }'.error TS2769: No overload matches this call.error TS2345: Argument of type 'TRelayEdge<TNode>' is not assignable to parameter of type 'Reference | StoreObject | undefined'.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
DiscussionIssues which may not have code impactIssues which may not have code impact
Activity
RyanCavanaugh commentedon Jun 9, 2022
kamranahmedse/developer-roadmap - Ryan
coder/code-server - Daniel
microsoft/playwright - Andrew
vercel/hyper - Ryan
react-hook-form/react-hook-form - Daniel
typeorm/typeorm - Andrew
mobxjs/mobx - Ryan
palantir/blueprint - Daniel
apollographql/apollo-client - Andrew
collate
kamranahmedse/developer-roadmap - Ryan
mobxjs/mobx - Ryan
vercel/hyper - Ryan
react-hook-form/react-hook-form - Daniel
coder/code-server - Daniel
palantir/blueprint - Daniel
microsoft/playwright - Andrew
typeorm/typeorm - Andrew
apollographql/apollo-client - Andrew
RyanCavanaugh commentedon Jun 9, 2022
kamranahmedse/developer-roadmap
Here,
Kis defaulted to{ }but unconstrained.DescendantsManager's second type argument is constrained:K extends Record<string, any> = {}. There are two instances in this file. Addingextends Record<string, any>to both instances fixes the errors with no follow-on errors.ahejlsberg commentedon Jun 9, 2022
Note that I would expect a significant number of these to result from the fact that an unconstrained type parameter is no longer assignable to
{}orRecord<string, any>in--strictNullChecksmode (introduced in #49119, which re-incorporated the change from #48366). Those are entirely appropriate new errors since an unconstrained type parameter could benullorundefined.RyanCavanaugh commentedon Jun 9, 2022
mobxjs/mobx
This method called
objecthas an unconstrained type parameter defaulted toany:it calls
extendsObservablewhich has a constraint ofObject(yes,Object) on both of its type parameters:Adding
extends objecttoTfixes the error with no follow-on errors.RyanCavanaugh commentedon Jun 9, 2022
vercel/hyper
All these breaks were in external .d.ts files.
confhadwhere
Conf<T>was constrainedThis was fixable by upstreaming the constraint
type-festhad two instancesThis required two layers of upstreaming the constraint, which in turn broke another package (
electron-store) because we surfaced the constraint onExcept's first type argument:sandersn commentedon Jun 9, 2022
I believe
confandtype-festhave fixes in their newest versions.Edit: I double-checked, and they do.
Edit 2:
electron-storealso has a fix, but it hasn't shipped yet. I pinged Sindre about it.Edit 3: electron-store shipped its fix about 10 hours ago.
andrewbranch commentedon Jun 9, 2022
playwright
Ostensibly a missing constraint on the type parameter of a subclass whose superclass required a constraint. However, the type of said type parameter is never meaningfully witnessed in the subclass. Its only usage is like this:
and then
resultis returned in a method whose return type isany, and the one caller of that method does not use the return value. In other words, this error did not catch a bug in practice, because the offending type parameter should never have been declared in the first place.typeorm
Every issue was resolvable by adding a missing constraint. The appropriate constraint, for internal consistency, was an interface called
ObjectLiteraldefined as just a string-to-any index signature. It seems likeextends objector evenextends {}would have squelched the errors due to the very loose assignability of that index signature, but it seemed like the correct thing was to propagateObjectLiteralthrough, so the codefix wasn’t usable where offered. I also noticed that there were places where the codefix wasn’t offered due to the failing assignment being of the array formT[] is not assignable to ObjectLiteral[]. I also noticed one instance where the codefix would have been good, and the related diagnostic “...probably needs anextends objectconstraint” was attached, but there was no corresponding codefix.Did this catch a real bug: I think so? It’s really hard to tell. The unconstrained
Entitytype parameters are treated like opaque values throughout most of the codebase. I finally traced it down to where it does some object operations on those values, and some of those functions actually guard againstnullandundefinedeven though the existing types refute that possibility. Others guard only againstundefined, and others do not check for either. So, I’m pretty sure in 4.7 it would have been possible to invoke something withnulland/orundefinedand find something that crashes like 20 stack frames later.apollo-client
First one I looked at showed the codefix / related diagnostic as buggy again; duplicated related info and no codefix:
Second one, related diagnostic is correct but again no codefix. Starting to wonder if the codefix ever works?
A couple more and it appears that this codebase has probably mistaken type parameter defaults for constraints through and through. Virtually every type parameter has a default and no constraint. Many of the defaults are
any. I tried to see if I could trace one down to where it would crash, but the values of these unconstrained type parameters almost always get assigned to a property that was optional, so down the line, the code tends to guard against falsy values. It seems 100% clear that anobjectconstraint is the intent, but I can’t easily find a place where anullorundefinedwould not be gracefully handled. (This is basically what I expected to find in all of these: yes, the types are clearly wrong; yes, because the types are wrong, it would be easy to make a code change that type checks but crashes at runtime; no, I cannot find existing instances of code like that.)DanielRosenwasser commentedon Jun 10, 2022
react-hook-form
createFormControl, there's an unconstrainedUwhich is used against an all-optional object type calledSetValueConfig.Ushould have had a meaningful constraint that extended that type.form.ts,getProxyFormState.ts,getResolverOptions.ts,fieldArray.ts,resolvers.ts, and others aTFieldValuesprobably should alwaysextends FieldValues, though it's just an alias forRecord<string, any>. So there is readability intent, but this is the same as just addingobjectfor most cases.getFieldAsValue.tsandvalidateField.ts- but it's not from the stronger check on generics, it's from the improved narrowing. At the end of the day, there's 100% no reason that these functions had to be generic though..d.tsfileI sent the fixes upstream over at react-hook-form/react-hook-form#8484.
code-server
This repo feels kind of like a less-than-useful benchmark because it's just letting us report over an old copy of VS Code; but I guess it gave us a chance to rerun on VS Code from before they dealt with this break over two months ago (microsoft/vscode@46abb2b). In theory this double type assertion should no longer be necessary Matt Bierner (@mjbvz).
Otherwise, Matt Bierner (@mjbvz) already upgraded to a recent nightly and fixed other breaks due to narrowing, this one involving how functions are no longer narrowed (microsoft/vscode@640898d).
Since there was no work for me to do, I will have to defer to the VS Code team's feedback.
blueprint
I spent a bit of time last week trying to figure this one out with Anders Hejlsberg (@ahejlsberg). It seems like we have regressed in some capacity with respect to destructuring defaults. Andrew Branch (@andrewbranch) might know more about this since he played around with destructuring recently, but I don't recall the exact change or whether it's even relevant.
It seems like every single break here comes from this. There's not a clear fix, and it seems like a regression, so I didn't try fixing it (though I spent a lot of time getting a minimal repro).
DanielRosenwasser commentedon Jun 10, 2022
I opened up #49480 for the
{}default issue, which was introduced by the intersection reduction PR at #49119 Anders Hejlsberg (@ahejlsberg).DanielRosenwasser commentedon Jun 13, 2022
Have others sent PRs to these projects? I sent out
DummyChannelOwnerfor (upcoming) TypeScript 4.8 playwright#14840RyanCavanaugh commentedon Jun 13, 2022
type-fest seems to have been updated already
I sent a PR to the other project
build: Fix build errors in TypeScript 4.8
andrewbranch commentedon Jun 13, 2022
fix: support for TypeScript 4.8 (#9106)