Skip to content

Experiment: Remove lower priority from contextual signature instantiation return type inference - #58321

Closed
Andrew Branch (andrewbranch) wants to merge 2 commits into
microsoft:mainfrom
andrewbranch:experiment/contextual-instantiation-priority
Closed

Andrew Branch (andrewbranch) wants to merge 2 commits into
microsoft:mainfrom
andrewbranch:experiment/contextual-instantiation-priority

Conversation

@andrewbranch

Copy link
Copy Markdown
Member

No description provided.

@andrewbranch

Copy link
Copy Markdown
Member Author

TypeScript Bot (@typescript-bot) test top200

@typescript-bot

TypeScript Bot (typescript-bot) commented Apr 25, 2024 •

Copy link
Copy Markdown
Contributor

Starting jobs; this comment will be updated as builds start and complete.

Command Status Results
test top200 ✅ Started

@andrewbranch

Copy link
Copy Markdown
Member Author

TypeScript Bot (@typescript-bot) pack this

@typescript-bot

TypeScript Bot (typescript-bot) commented Apr 25, 2024 •

Copy link
Copy Markdown
Contributor

Starting jobs; this comment will be updated as builds start and complete.

Command Status Results
pack this ✅ Started ✅ Results

@typescript-bot

TypeScript Bot (typescript-bot) commented Apr 25, 2024 •

Copy link
Copy Markdown
Contributor

Hey Andrew Branch (@andrewbranch), 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/161473/artifacts?artifactName=tgz&fileId=C723169543A40FB90A0107AC550ACF4D6B41276B124BA86254E134BF631E468F02&fileName=/typescript-5.5.0-insiders.20240425.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.5.0-pr-58321-4".;

@andrewbranch

Copy link
Copy Markdown
Member Author

@typescript-bot

TypeScript Bot (typescript-bot) commented Apr 25, 2024 •

Copy link
Copy Markdown
Contributor

Starting jobs; this comment will be updated as builds start and complete.

Command Status Results
test top200 ✅ Started 👀 Results
pack this ✅ Started ✅ Results

@typescript-bot

TypeScript Bot (typescript-bot) commented Apr 25, 2024 •

Copy link
Copy Markdown
Contributor

Hey Andrew Branch (@andrewbranch), 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/161474/artifacts?artifactName=tgz&fileId=0D50580727580C2B54AFD5A51B91EA4A6271481DD62F02A2B1CEE60EA09EF4C902&fileName=/typescript-5.5.0-insiders.20240425.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.5.0-pr-58321-7".;

!!! error TS2322: Type 'Obj[K]' is not assignable to type 'U[K]'.
!!! error TS2322: Type 'Obj' is not assignable to type 'U'.
!!! error TS2322: 'U' could be instantiated with an arbitrary type which could be unrelated to 'Obj'. No newline at end of file
!!! error TS2322: Type '{ [K in keyof U]: Obj[K]; }' is not assignable to type '{ [x: string]: number; }'.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wrote this test to exercise a very specific inference code path in the PR that introduced it, so it's not grounded in a real world scenario, but I don't think the new error is worse? Maybe the connection between the error and the actual code is more surprising now just because we end up inferring T = { [x: string]: number } instead of T = U.

Maybe that's a separate problem with signature comparison: it's not immediately clear to users that we've done inference in order to compare two signatures, and it's not immediately clear what the result of that inference was.

@typescript-bot

Copy link
Copy Markdown
Contributor

Andrew Branch (@andrewbranch) Here are the results of running the top 400 repos comparing main and refs/pull/58321/merge:

Something interesting changed - please have a look.

Details

gcanti/fp-ts

4 of 5 projects failed to build with the old tsc and were ignored

tsconfig.build-es6.json

  • error TS2345: Argument of type '<A>(a: A) => Either<E, NonNullable<A>>' is not assignable to parameter of type '(b: B | null | undefined) => Either<E, B & {}>'.
  • error TS2345: Argument of type '<A>(a: A) => HKT<F, Either<E, NonNullable<A>>>' is not assignable to parameter of type '(b: B | null | undefined) => HKT<F, Either<E, B & {}>>'.
  • error TS2322: Type '<A extends readonly unknown[]>(...eqs: { [K in keyof A]: Eq<A[K]>; }) => Eq<Readonly<A>>' is not assignable to type '<T extends readonly Eq<any>[]>(...eqs: T) => Eq<{ [K in keyof T]: T[K] extends Eq<infer A> ? A : never; }>'.
  • error TS2345: Argument of type '<A>(a: A) => Option<NonNullable<A>>' is not assignable to parameter of type '(b: B | null | undefined) => Option<B & {}>'.
  • error TS2345: Argument of type '<A>(a: A) => HKT<F, Option<NonNullable<A>>>' is not assignable to parameter of type '(b: B | null | undefined) => HKT<F, Option<B & {}>>'.
  • error TS2322: Type '<A extends readonly unknown[]>(...ords: { [K in keyof A]: Ord<A[K]>; }) => Ord<Readonly<A>>' is not assignable to type '<T extends readonly Ord<any>[]>(...ords: T) => Ord<{ [K in keyof T]: T[K] extends Ord<infer A> ? A : never; }>'.
  • error TS2322: Type '<A extends readonly unknown[]>(...shows: { [K in keyof A]: Show<A[K]>; }) => Show<Readonly<A>>' is not assignable to type '<T extends readonly Show<any>[]>(...shows: T) => Show<{ [K in keyof T]: T[K] extends Show<infer A> ? A : never; }>'.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants