Update parseInt parameter name and jsdoc (#42756)

* feat(lib): improve parseInt type definition and docstring

* Accepted baselines

* update tests
This commit is contained in:
Sang
2021-03-05 11:23:08 -08:00
committed by GitHub
parent 25375a2213
commit 612a96e161
10 changed files with 78 additions and 78 deletions
+2 -2
View File
@@ -248,8 +248,8 @@ interface NumberConstructor {
/**
* Converts A string to an integer.
* @param s A string to convert into a number.
* @param radix A value between 2 and 36 that specifies the base of the number in numString.
* @param string A string to convert into a number.
* @param radix A value between 2 and 36 that specifies the base of the number in `string`.
* If this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal.
* All other strings are considered decimal.
*/
+3 -3
View File
@@ -13,12 +13,12 @@ declare function eval(x: string): any;
/**
* Converts a string to an integer.
* @param s A string to convert into a number.
* @param radix A value between 2 and 36 that specifies the base of the number in numString.
* @param string A string to convert into a number.
* @param radix A value between 2 and 36 that specifies the base of the number in `string`.
* If this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal.
* All other strings are considered decimal.
*/
declare function parseInt(s: string, radix?: number): number;
declare function parseInt(string: string, radix?: number): number;
/**
* Converts a string to a floating-point number.
@@ -12,7 +12,7 @@ abstract class AbstractClass {
>this : this
>method : (num: number) => void
>parseInt(str) : number
>parseInt : (s: string, radix?: number) => number
>parseInt : (string: string, radix?: number) => number
>str : string
let val = this.prop.toLowerCase();
@@ -122,7 +122,7 @@
"kind": "punctuation"
},
{
"text": "s",
"text": "string",
"kind": "parameterName"
},
{
@@ -191,11 +191,11 @@
"tags": [
{
"name": "param",
"text": "s A string to convert into a number."
"text": "string A string to convert into a number."
},
{
"name": "param",
"text": "radix A value between 2 and 36 that specifies the base of the number in numString.\r\nIf this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal.\r\nAll other strings are considered decimal."
"text": "radix A value between 2 and 36 that specifies the base of the number in `string`.\r\nIf this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal.\r\nAll other strings are considered decimal."
}
]
},
@@ -9061,7 +9061,7 @@
"kind": "punctuation"
},
{
"text": "s",
"text": "string",
"kind": "parameterName"
},
{
@@ -9130,11 +9130,11 @@
"tags": [
{
"name": "param",
"text": "s A string to convert into a number."
"text": "string A string to convert into a number."
},
{
"name": "param",
"text": "radix A value between 2 and 36 that specifies the base of the number in numString.\r\nIf this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal.\r\nAll other strings are considered decimal."
"text": "radix A value between 2 and 36 that specifies the base of the number in `string`.\r\nIf this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal.\r\nAll other strings are considered decimal."
}
]
},
@@ -14051,7 +14051,7 @@
"kind": "punctuation"
},
{
"text": "s",
"text": "string",
"kind": "parameterName"
},
{
@@ -14120,11 +14120,11 @@
"tags": [
{
"name": "param",
"text": "s A string to convert into a number."
"text": "string A string to convert into a number."
},
{
"name": "param",
"text": "radix A value between 2 and 36 that specifies the base of the number in numString.\r\nIf this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal.\r\nAll other strings are considered decimal."
"text": "radix A value between 2 and 36 that specifies the base of the number in `string`.\r\nIf this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal.\r\nAll other strings are considered decimal."
}
]
},
@@ -22449,7 +22449,7 @@
"kind": "punctuation"
},
{
"text": "s",
"text": "string",
"kind": "parameterName"
},
{
@@ -22518,11 +22518,11 @@
"tags": [
{
"name": "param",
"text": "s A string to convert into a number."
"text": "string A string to convert into a number."
},
{
"name": "param",
"text": "radix A value between 2 and 36 that specifies the base of the number in numString.\r\nIf this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal.\r\nAll other strings are considered decimal."
"text": "radix A value between 2 and 36 that specifies the base of the number in `string`.\r\nIf this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal.\r\nAll other strings are considered decimal."
}
]
},
@@ -26299,7 +26299,7 @@
"kind": "punctuation"
},
{
"text": "s",
"text": "string",
"kind": "parameterName"
},
{
@@ -26368,11 +26368,11 @@
"tags": [
{
"name": "param",
"text": "s A string to convert into a number."
"text": "string A string to convert into a number."
},
{
"name": "param",
"text": "radix A value between 2 and 36 that specifies the base of the number in numString.\r\nIf this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal.\r\nAll other strings are considered decimal."
"text": "radix A value between 2 and 36 that specifies the base of the number in `string`.\r\nIf this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal.\r\nAll other strings are considered decimal."
}
]
},
@@ -30149,7 +30149,7 @@
"kind": "punctuation"
},
{
"text": "s",
"text": "string",
"kind": "parameterName"
},
{
@@ -30218,11 +30218,11 @@
"tags": [
{
"name": "param",
"text": "s A string to convert into a number."
"text": "string A string to convert into a number."
},
{
"name": "param",
"text": "radix A value between 2 and 36 that specifies the base of the number in numString.\r\nIf this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal.\r\nAll other strings are considered decimal."
"text": "radix A value between 2 and 36 that specifies the base of the number in `string`.\r\nIf this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal.\r\nAll other strings are considered decimal."
}
]
},
@@ -33999,7 +33999,7 @@
"kind": "punctuation"
},
{
"text": "s",
"text": "string",
"kind": "parameterName"
},
{
@@ -34068,11 +34068,11 @@
"tags": [
{
"name": "param",
"text": "s A string to convert into a number."
"text": "string A string to convert into a number."
},
{
"name": "param",
"text": "radix A value between 2 and 36 that specifies the base of the number in numString.\r\nIf this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal.\r\nAll other strings are considered decimal."
"text": "radix A value between 2 and 36 that specifies the base of the number in `string`.\r\nIf this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal.\r\nAll other strings are considered decimal."
}
]
},
@@ -37849,7 +37849,7 @@
"kind": "punctuation"
},
{
"text": "s",
"text": "string",
"kind": "parameterName"
},
{
@@ -37918,11 +37918,11 @@
"tags": [
{
"name": "param",
"text": "s A string to convert into a number."
"text": "string A string to convert into a number."
},
{
"name": "param",
"text": "radix A value between 2 and 36 that specifies the base of the number in numString.\r\nIf this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal.\r\nAll other strings are considered decimal."
"text": "radix A value between 2 and 36 that specifies the base of the number in `string`.\r\nIf this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal.\r\nAll other strings are considered decimal."
}
]
},
@@ -41699,7 +41699,7 @@
"kind": "punctuation"
},
{
"text": "s",
"text": "string",
"kind": "parameterName"
},
{
@@ -41768,11 +41768,11 @@
"tags": [
{
"name": "param",
"text": "s A string to convert into a number."
"text": "string A string to convert into a number."
},
{
"name": "param",
"text": "radix A value between 2 and 36 that specifies the base of the number in numString.\r\nIf this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal.\r\nAll other strings are considered decimal."
"text": "radix A value between 2 and 36 that specifies the base of the number in `string`.\r\nIf this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal.\r\nAll other strings are considered decimal."
}
]
},
@@ -122,7 +122,7 @@
"kind": "punctuation"
},
{
"text": "s",
"text": "string",
"kind": "parameterName"
},
{
@@ -191,11 +191,11 @@
"tags": [
{
"name": "param",
"text": "s A string to convert into a number."
"text": "string A string to convert into a number."
},
{
"name": "param",
"text": "radix A value between 2 and 36 that specifies the base of the number in numString.\r\nIf this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal.\r\nAll other strings are considered decimal."
"text": "radix A value between 2 and 36 that specifies the base of the number in `string`.\r\nIf this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal.\r\nAll other strings are considered decimal."
}
]
},
@@ -5358,7 +5358,7 @@
"kind": "punctuation"
},
{
"text": "s",
"text": "string",
"kind": "parameterName"
},
{
@@ -5427,11 +5427,11 @@
"tags": [
{
"name": "param",
"text": "s A string to convert into a number."
"text": "string A string to convert into a number."
},
{
"name": "param",
"text": "radix A value between 2 and 36 that specifies the base of the number in numString.\r\nIf this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal.\r\nAll other strings are considered decimal."
"text": "radix A value between 2 and 36 that specifies the base of the number in `string`.\r\nIf this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal.\r\nAll other strings are considered decimal."
}
]
},
@@ -11327,7 +11327,7 @@
"kind": "punctuation"
},
{
"text": "s",
"text": "string",
"kind": "parameterName"
},
{
@@ -11396,11 +11396,11 @@
"tags": [
{
"name": "param",
"text": "s A string to convert into a number."
"text": "string A string to convert into a number."
},
{
"name": "param",
"text": "radix A value between 2 and 36 that specifies the base of the number in numString.\r\nIf this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal.\r\nAll other strings are considered decimal."
"text": "radix A value between 2 and 36 that specifies the base of the number in `string`.\r\nIf this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal.\r\nAll other strings are considered decimal."
}
]
},
@@ -16347,7 +16347,7 @@
"kind": "punctuation"
},
{
"text": "s",
"text": "string",
"kind": "parameterName"
},
{
@@ -16416,11 +16416,11 @@
"tags": [
{
"name": "param",
"text": "s A string to convert into a number."
"text": "string A string to convert into a number."
},
{
"name": "param",
"text": "radix A value between 2 and 36 that specifies the base of the number in numString.\r\nIf this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal.\r\nAll other strings are considered decimal."
"text": "radix A value between 2 and 36 that specifies the base of the number in `string`.\r\nIf this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal.\r\nAll other strings are considered decimal."
}
]
},
@@ -21345,7 +21345,7 @@
"kind": "punctuation"
},
{
"text": "s",
"text": "string",
"kind": "parameterName"
},
{
@@ -21414,11 +21414,11 @@
"tags": [
{
"name": "param",
"text": "s A string to convert into a number."
"text": "string A string to convert into a number."
},
{
"name": "param",
"text": "radix A value between 2 and 36 that specifies the base of the number in numString.\r\nIf this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal.\r\nAll other strings are considered decimal."
"text": "radix A value between 2 and 36 that specifies the base of the number in `string`.\r\nIf this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal.\r\nAll other strings are considered decimal."
}
]
},
@@ -26593,7 +26593,7 @@
"kind": "punctuation"
},
{
"text": "s",
"text": "string",
"kind": "parameterName"
},
{
@@ -26662,11 +26662,11 @@
"tags": [
{
"name": "param",
"text": "s A string to convert into a number."
"text": "string A string to convert into a number."
},
{
"name": "param",
"text": "radix A value between 2 and 36 that specifies the base of the number in numString.\r\nIf this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal.\r\nAll other strings are considered decimal."
"text": "radix A value between 2 and 36 that specifies the base of the number in `string`.\r\nIf this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal.\r\nAll other strings are considered decimal."
}
]
},
@@ -32562,7 +32562,7 @@
"kind": "punctuation"
},
{
"text": "s",
"text": "string",
"kind": "parameterName"
},
{
@@ -32631,11 +32631,11 @@
"tags": [
{
"name": "param",
"text": "s A string to convert into a number."
"text": "string A string to convert into a number."
},
{
"name": "param",
"text": "radix A value between 2 and 36 that specifies the base of the number in numString.\r\nIf this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal.\r\nAll other strings are considered decimal."
"text": "radix A value between 2 and 36 that specifies the base of the number in `string`.\r\nIf this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal.\r\nAll other strings are considered decimal."
}
]
},
@@ -122,7 +122,7 @@
"kind": "punctuation"
},
{
"text": "s",
"text": "string",
"kind": "parameterName"
},
{
@@ -191,11 +191,11 @@
"tags": [
{
"name": "param",
"text": "s A string to convert into a number."
"text": "string A string to convert into a number."
},
{
"name": "param",
"text": "radix A value between 2 and 36 that specifies the base of the number in numString.\r\nIf this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal.\r\nAll other strings are considered decimal."
"text": "radix A value between 2 and 36 that specifies the base of the number in `string`.\r\nIf this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal.\r\nAll other strings are considered decimal."
}
]
},
@@ -4461,7 +4461,7 @@
"kind": "punctuation"
},
{
"text": "s",
"text": "string",
"kind": "parameterName"
},
{
@@ -4530,11 +4530,11 @@
"tags": [
{
"name": "param",
"text": "s A string to convert into a number."
"text": "string A string to convert into a number."
},
{
"name": "param",
"text": "radix A value between 2 and 36 that specifies the base of the number in numString.\r\nIf this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal.\r\nAll other strings are considered decimal."
"text": "radix A value between 2 and 36 that specifies the base of the number in `string`.\r\nIf this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal.\r\nAll other strings are considered decimal."
}
]
},
@@ -7635,7 +7635,7 @@
"kind": "punctuation"
},
{
"text": "s",
"text": "string",
"kind": "parameterName"
},
{
@@ -7704,11 +7704,11 @@
"tags": [
{
"name": "param",
"text": "s A string to convert into a number."
"text": "string A string to convert into a number."
},
{
"name": "param",
"text": "radix A value between 2 and 36 that specifies the base of the number in numString.\r\nIf this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal.\r\nAll other strings are considered decimal."
"text": "radix A value between 2 and 36 that specifies the base of the number in `string`.\r\nIf this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal.\r\nAll other strings are considered decimal."
}
]
},
@@ -122,7 +122,7 @@
"kind": "punctuation"
},
{
"text": "s",
"text": "string",
"kind": "parameterName"
},
{
@@ -191,11 +191,11 @@
"tags": [
{
"name": "param",
"text": "s A string to convert into a number."
"text": "string A string to convert into a number."
},
{
"name": "param",
"text": "radix A value between 2 and 36 that specifies the base of the number in numString.\r\nIf this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal.\r\nAll other strings are considered decimal."
"text": "radix A value between 2 and 36 that specifies the base of the number in `string`.\r\nIf this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal.\r\nAll other strings are considered decimal."
}
]
},
@@ -3667,7 +3667,7 @@
"kind": "punctuation"
},
{
"text": "s",
"text": "string",
"kind": "parameterName"
},
{
@@ -3736,11 +3736,11 @@
"tags": [
{
"name": "param",
"text": "s A string to convert into a number."
"text": "string A string to convert into a number."
},
{
"name": "param",
"text": "radix A value between 2 and 36 that specifies the base of the number in numString.\r\nIf this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal.\r\nAll other strings are considered decimal."
"text": "radix A value between 2 and 36 that specifies the base of the number in `string`.\r\nIf this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal.\r\nAll other strings are considered decimal."
}
]
},
@@ -8167,7 +8167,7 @@
"kind": "punctuation"
},
{
"text": "s",
"text": "string",
"kind": "parameterName"
},
{
@@ -8236,11 +8236,11 @@
"tags": [
{
"name": "param",
"text": "s A string to convert into a number."
"text": "string A string to convert into a number."
},
{
"name": "param",
"text": "radix A value between 2 and 36 that specifies the base of the number in numString.\r\nIf this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal.\r\nAll other strings are considered decimal."
"text": "radix A value between 2 and 36 that specifies the base of the number in `string`.\r\nIf this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal.\r\nAll other strings are considered decimal."
}
]
},
@@ -11712,7 +11712,7 @@
"kind": "punctuation"
},
{
"text": "s",
"text": "string",
"kind": "parameterName"
},
{
@@ -11781,11 +11781,11 @@
"tags": [
{
"name": "param",
"text": "s A string to convert into a number."
"text": "string A string to convert into a number."
},
{
"name": "param",
"text": "radix A value between 2 and 36 that specifies the base of the number in numString.\r\nIf this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal.\r\nAll other strings are considered decimal."
"text": "radix A value between 2 and 36 that specifies the base of the number in `string`.\r\nIf this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal.\r\nAll other strings are considered decimal."
}
]
},
+2 -2
View File
@@ -1,10 +1,10 @@
=== tests/cases/compiler/externFunc.ts ===
declare function parseInt(s:string):number;
>parseInt : { (s: string, radix?: number): number; (s: string): number; }
>parseInt : { (string: string, radix?: number): number; (s: string): number; }
>s : string
parseInt("2");
>parseInt("2") : number
>parseInt : { (s: string, radix?: number): number; (s: string): number; }
>parseInt : { (string: string, radix?: number): number; (s: string): number; }
>"2" : "2"
@@ -733,7 +733,7 @@ module TypeScript {
var charCode = parseInt(name.substr(i + 2, 4), 16);
>charCode : number
>parseInt(name.substr(i + 2, 4), 16) : number
>parseInt : (s: string, radix?: number) => number
>parseInt : (string: string, radix?: number) => number
>name.substr(i + 2, 4) : string
>name.substr : (from: number, length?: number) => string
>name : string