Issue 1:
I tried using the @types/xxxx package and had problems.

I tried using the latest stable version of tsc. https://www.npmjs.com/package/typescript

I have a question that is inappropriate for StackOverflow. (Please ask any appropriate questions there).

Mention the authors (see Definitions by: in index.d.ts) so they can respond.

Authors: Tagging @ejose19 and @iansan5653 for their input based on git blame. Also tagging library author @jquense

How should I resolve issue with providing correct predicate type

Below is the example code which throws type errors after upgrading yup to 0.29.3 and @types/yup to 0.29.7

code: Yup.string()
.required('Code is required.')
.test('duplicate-record', 'Code must be unique.', function (this: Yup.TestContext, code: string) {
for (const [i, r] of allocationTable.records.entries()) {
if (code === r.code && `records[${i}].code` !== this.path) {
return false;
}
}
return true;
}),

In this above example it looks if the code that user entered already exists in records entry and returns true if its unique else false if it already exists.

Here I'm checking if code is unique or not and returning boolean and I'm not checking if the code is string which apparently resolves the issue and I'm not sure if this is the right usage.

Type error that I get for above function is:

Argument of type '(this: TestContext<object>, code: string) => boolean' is not assignable to parameter of type 'AssertingTestFunction<any, object>'.
Signature '(this: TestContext<object>, code: string): boolean' must be a type predicate.ts(2345)

AssertingTestFunction declaration looks like below in Yup Typings:

export type AssertingTestFunction<T, C> = (this: TestContext<C>, value: any) => value is T;

Another example code is:

customerKey: Yup.object<CustomerKey>()
.nullable(true)
.shape({
customerId: Yup.number(),
customerCode: Yup.string().test('customerCodeTest', 'Customer is required', (value) => {
return (
formProps.eventType === TypeA ||
(formProps.eventType === TypeB && value) // <------ Only required if eventType B is picked
);
}),
}),

For this code test I'm checking and returning value (truthy or falsy) only if TypeB is picked else returning true. Again I'm not checking if the value is string rather existence of the value itself for a certain eventType (separate field) selection.

Here's typing error for above code:

Argument of type '(this: TestContext<object>, value: string | null | undefined) => string | boolean | null | undefined' is not assignable to parameter of type 'AssertingTestFunction<any, object>'.
Signature '(this: TestContext<object>, value: string | null | undefined): string | boolean | null | undefined' must be a type predicate.ts(2345)

Issue 2:
If you know how to fix the issue, make a pull request instead.

[] I tried using the @types/jQuery package and had problems.

I tried using the latest stable version of tsc. https://www.npmjs.com/package/typescript

I have a question that is inappropriate for StackOverflow. (Please ask any appropriate questions there).

Mention the authors (see Definitions by: in index.d.ts) so they can respond.

Authors: @leonard-thieu, @borisyankov @choffmeister

How to extend the JQuery interface to support jQuery plugin methods where the options parameter has an Enum property.

The problem with the below approach is, I have to create a separate module EnumCircleShape.ts and import it into my app.ts file.

While this works, it duplicates code (Enum in d.ts and EnumCircleShape.ts) and an additional import is required, in order to use the plugin in app.ts.

If I remove the import from app.ts I can successfully transpile with tsc, but then I get a runtime error:

It works without importing if I remove the enum property of the IOptions interface. But this isn't a solution.

Usage (app.ts):

import { CircleShape } from "./EnumCircleShape";

$("#slider").roundSlider({
step: 20,
circleShape: CircleShape.customQuarter
});

jQueryInterfaceExtensions.d.ts

interface JQuery {
roundSlider(options: IOptions | string): jQuery;
}

interface IOptions {
circleShape?: CircleShape;
}

enum CircleShape {
full = "full",
halfTop = "half-top"
}

EnumCircleShape.ts

enum CircleShape {
full = "full",
halfTop = "half-top"
}

It would be good to make a little advanced tutorial how to extend JQuery as many plugins don't have a .d.ts available.