-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Add TS types for Check
, remove circular dependency
#11901
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
/** | ||
* Contains functions for checking that supplied arguments are of a specified type | ||
* or meet specified conditions | ||
*/ | ||
export const Check: { | ||
/** | ||
* Throws if test is not defined | ||
* | ||
* @param {string} name The name of the variable being tested | ||
* @param {*} test The value that is to be checked | ||
* @exception {DeveloperError} test must be defined | ||
*/ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you explain why the inline docs need to be duplicated? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Without them the intellisense that VSCode picks up has no description of any of the functions. The way the build is adding this it's taking the file wholesale. I was not able to find a way to get the |
||
defined<T>(name: string, test: T): asserts test is NonNullable<T>; | ||
/** | ||
* Contains type checking functions, all using the typeof operator | ||
*/ | ||
typeOf: { | ||
/** | ||
* Throws if test is not typeof 'string' | ||
* | ||
* @param {string} name The name of the variable being tested | ||
* @param {*} test The value to test | ||
* @exception {DeveloperError} test must be typeof 'string' | ||
*/ | ||
string(name: string, test: any): asserts test is string; | ||
/** | ||
* Throws if test is not typeof 'function' | ||
* | ||
* @param {string} name The name of the variable being tested | ||
* @param {*} test The value to test | ||
* @exception {DeveloperError} test must be typeof 'function' | ||
*/ | ||
func(name: string, test: any): asserts test is Function; | ||
/** | ||
* Throws if test is not typeof 'object' | ||
* | ||
* @param {string} name The name of the variable being tested | ||
* @param {*} test The value to test | ||
* @exception {DeveloperError} test must be typeof 'object' | ||
*/ | ||
object(name: string, test: any): asserts test is object; | ||
/** | ||
* Throws if test is not typeof 'boolean' | ||
* | ||
* @param {string} name The name of the variable being tested | ||
* @param {*} test The value to test | ||
* @exception {DeveloperError} test must be typeof 'boolean' | ||
*/ | ||
bool(name: string, test: any): asserts test is boolean; | ||
/** | ||
* Throws if test is not typeof 'bigint' | ||
* | ||
* @param {string} name The name of the variable being tested | ||
* @param {*} test The value to test | ||
* @exception {DeveloperError} test must be typeof 'bigint' | ||
*/ | ||
bigint(name: string, test: any): asserts test is bigint; | ||
/** | ||
* Throws if test is not typeof 'number' | ||
* | ||
* @param {string} name The name of the variable being tested | ||
* @param {*} test The value to test | ||
* @exception {DeveloperError} test must be typeof 'number' | ||
*/ | ||
number: { | ||
(name: string, test: any): void; | ||
/** | ||
* Throws if test is not typeof 'number' and less than limit | ||
* | ||
* @param {string} name The name of the variable being tested | ||
* @param {*} test The value to test | ||
* @param {number} limit The limit value to compare against | ||
* @exception {DeveloperError} test must be typeof 'number' and less than limit | ||
*/ | ||
lessThan(name: string, test: any, limit: number): asserts test is number; | ||
/** | ||
* Throws if test is not typeof 'number' and less than or equal to limit | ||
* | ||
* @param {string} name The name of the variable being tested | ||
* @param {*} test The value to test | ||
* @param {number} limit The limit value to compare against | ||
* @exception {DeveloperError} test must be typeof 'number' and less than or equal to limit | ||
*/ | ||
lessThanOrEquals( | ||
name: string, | ||
test: any, | ||
limit: number | ||
): asserts test is number; | ||
/** | ||
* Throws if test is not typeof 'number' and greater than limit | ||
* | ||
* @param {string} name The name of the variable being tested | ||
* @param {*} test The value to test | ||
* @param {number} limit The limit value to compare against | ||
* @exception {DeveloperError} test must be typeof 'number' and greater than limit | ||
*/ | ||
greaterThan( | ||
name: string, | ||
test: any, | ||
limit: number | ||
): asserts test is number; | ||
/** | ||
* Throws if test is not typeof 'number' and greater than or equal to limit | ||
* | ||
* @param {string} name The name of the variable being tested | ||
* @param {*} test The value to test | ||
* @param {number} limit The limit value to compare against | ||
* @exception {DeveloperError} test must be typeof 'number' and greater than or equal to limit | ||
*/ | ||
greaterThanOrEquals( | ||
name: string, | ||
test: any, | ||
limit: number | ||
): asserts test is number; | ||
/** | ||
* Throws if test1 and test2 is not typeof 'number' and not equal in value | ||
* | ||
* @param {string} name1 The name of the first variable being tested | ||
* @param {string} name2 The name of the second variable being tested against | ||
* @param {*} test1 The value to test | ||
* @param {*} test2 The value to test against | ||
* @exception {DeveloperError} test1 and test2 should be type of 'number' and be equal in value | ||
*/ | ||
equals(name1: string, name2: string, test1: any, test2: any): void; | ||
}; | ||
}; | ||
}; |
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.
Can this be made generic to and
**/Source/**/*.d.ts
file? That way any future additions don't need to tweak build code.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 would love to do that but I couldn't find or think of a nice clean way to do that. As it is it needs to be specific to replace the definition in the types file for the corresponding code. Otherwise we'd end up with a duplicated definition which breaks TS. I'd love if
tsd-jsdoc
let you pass in a set of types files to use in places like this.