-
-
Notifications
You must be signed in to change notification settings - Fork 926
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
Upgrade to TypeScript 3.9 #1267
Conversation
I think this is caused by microsoft/TypeScript#38540 |
The linked TypeScript bug also causes the current version of got to fail when using TS 3.9. The issue occurs when you mix the default import with type imports (i.e. A workaround I found is to add The right answer might be to just wait for TypeScript to fix the problem, |
We should have a fix at microsoft/TypeScript#38808. If you can pick up the build that will be produced at the bottom of the page and try it out, that'd really help give us some confidence that we can back-port it to 3.9. |
I tried it in d6dae82, and seems like it doesn't fix our issue, but it doesn't cause any other problems either. |
@@ -197,6 +198,7 @@ const create = (defaults: InstanceDefaults): Got => { | |||
|
|||
// Pagination | |||
const paginateEach = (async function * <T, R>(url: string | URL, options?: OptionsWithPagination<T, R>) { | |||
// @ts-expect-error |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have no idea how to fix it. I just punted it as it's more important to get TS upgraded:
source/create.ts:201:51 - error TS2345: Argument of type 'Merge<Options, PaginationOptions<T, R>> | undefined' is not assignable to parameter of type 'Options | undefined'.
Type 'Merge<Options, PaginationOptions<T, R>>' is not assignable to type 'Options | undefined'.
Type 'Merge<Options, PaginationOptions<T, R>>' is not assignable to type 'Options'.
Types of property 'pagination' are incompatible.
Type '{ transform?: ((response: Response<R>) => T[] | Promise<T[]>) | undefined; filter?: ((item: T, allItems: T[], currentItems: T[]) => boolean) | undefined; ... 4 more ...; stackAllItems?: boolean | undefined; } | undefined' is not assignable to type '{ transform?: ((response: Response<unknown>) => unknown[] | Promise<unknown[]>) | undefined; filter?: ((item: unknown, allItems: unknown[], currentItems: unknown[]) => boolean) | undefined; paginate?: ((response: Response<unknown>, allItems: unknown[], currentItems: unknown[]) => false | Options) | undefined; should...'.
Type '{ transform?: ((response: Response<R>) => T[] | Promise<T[]>) | undefined; filter?: ((item: T, allItems: T[], currentItems: T[]) => boolean) | undefined; ... 4 more ...; stackAllItems?: boolean | undefined; }' is not assignable to type '{ transform?: ((response: Response<unknown>) => unknown[] | Promise<unknown[]>) | undefined; filter?: ((item: unknown, allItems: unknown[], currentItems: unknown[]) => boolean) | undefined; paginate?: ((response: Response<unknown>, allItems: unknown[], currentItems: unknown[]) => false | Options) | undefined; should...'.
Types of property 'transform' are incompatible.
Type '((response: Response<R>) => T[] | Promise<T[]>) | undefined' is not assignable to type '((response: Response<unknown>) => unknown[] | Promise<unknown[]>) | undefined'.
Type '(response: Response<R>) => T[] | Promise<T[]>' is not assignable to type '(response: Response<unknown>) => unknown[] | Promise<unknown[]>'.
Types of parameters 'response' and 'response' are incompatible.
Type 'Response<unknown>' is not assignable to type 'Response<R>'.
Type 'unknown' is not assignable to type 'R'.
'R' could be instantiated with an arbitrary type which could be unrelated to 'unknown'.
201 let normalizedOptions = normalizeArguments(url, options, defaults.options);
~~~~~~~
Found 1 error.
I'll add a TODO comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TS 3.9 introduced a lot of issues, and it seems many will be fixed in TS 4, so I suggest ignoring it until then.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Simplest repro:
interface Options<T = unknown> {
fn: (value: T) => void
}
const normalizeOptions = (options: Options): void => {};
function someOtherFunction<T>(options: Options<T>) {
normalizeOptions(options);
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replacing unknown
with any
seems to fix the issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interestingly the example reproduces the error on all TS 3.x versions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey, you precious wizard! How have you achieved that? :P
No description provided.