mirror of
https://github.com/react/react-native-devtools-frontend.git
synced 2026-10-07 04:26:32 +08:00
[ts] Type-check ui/Geometry.js with TypeScript
Bug: chromium:1011811 Change-Id: I4680d84aa2410a050a1d92d523570ac45471ed12 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2382857 Commit-Queue: Mathias Bynens <mathias@chromium.org> Reviewed-by: Simon Zünd <szuend@chromium.org>
This commit is contained in:
committed by
Commit Bot
parent
791d4882f5
commit
59d25cd7ff
Vendored
+4
-1
@@ -25,6 +25,9 @@ type ITemplateArray = TemplateStringsArray
|
||||
// Type alias for the type that has been removed in Chrome 54.
|
||||
type FileError = DOMError;
|
||||
|
||||
// Type alias for DOMMatrix, formerly known as WebKitCSSMatrix.
|
||||
type CSSMatrix = DOMMatrix;
|
||||
|
||||
interface String {
|
||||
compareTo(other: string): number;
|
||||
trimEndWithMaxLength(maxLength: number): string;
|
||||
@@ -160,4 +163,4 @@ interface ServicePort {
|
||||
send(message: string): Promise<boolean>;
|
||||
|
||||
close(): Promise<boolean>;
|
||||
}
|
||||
}
|
||||
|
||||
+13
-15
@@ -28,9 +28,6 @@
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
// @ts-nocheck
|
||||
// TODO(crbug.com/1011811): Enable TypeScript compiler checks
|
||||
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
@@ -131,8 +128,8 @@ export class CubicBezier {
|
||||
static parse(text) {
|
||||
const keywordValues = CubicBezier.KeywordValues;
|
||||
const value = text.toLowerCase().replace(/\s+/g, '');
|
||||
if (Object.keys(keywordValues).indexOf(value) !== -1) {
|
||||
return CubicBezier.parse(keywordValues[value]);
|
||||
if (keywordValues.has(value)) {
|
||||
return CubicBezier.parse(/** @type {string} */ (keywordValues.get(value)));
|
||||
}
|
||||
const bezierRegex = /^cubic-bezier\(([^,]+),([^,]+),([^,]+),([^,]+)\)$/;
|
||||
const match = value.match(bezierRegex);
|
||||
@@ -169,8 +166,8 @@ export class CubicBezier {
|
||||
asCSSText() {
|
||||
const raw = 'cubic-bezier(' + this.controlPoints.join(', ') + ')';
|
||||
const keywordValues = CubicBezier.KeywordValues;
|
||||
for (const keyword in keywordValues) {
|
||||
if (raw === keywordValues[keyword]) {
|
||||
for (const [keyword, value] of keywordValues) {
|
||||
if (raw === value) {
|
||||
return keyword;
|
||||
}
|
||||
}
|
||||
@@ -181,13 +178,14 @@ export class CubicBezier {
|
||||
/** @type {!RegExp} */
|
||||
CubicBezier.Regex = /((cubic-bezier\([^)]+\))|\b(linear|ease-in-out|ease-in|ease-out|ease)\b)/g;
|
||||
|
||||
CubicBezier.KeywordValues = {
|
||||
'linear': 'cubic-bezier(0, 0, 1, 1)',
|
||||
'ease': 'cubic-bezier(0.25, 0.1, 0.25, 1)',
|
||||
'ease-in': 'cubic-bezier(0.42, 0, 1, 1)',
|
||||
'ease-in-out': 'cubic-bezier(0.42, 0, 0.58, 1)',
|
||||
'ease-out': 'cubic-bezier(0, 0, 0.58, 1)'
|
||||
};
|
||||
/** @type {!Map<string, string>} */
|
||||
CubicBezier.KeywordValues = new Map([
|
||||
['linear', 'cubic-bezier(0, 0, 1, 1)'],
|
||||
['ease', 'cubic-bezier(0.25, 0.1, 0.25, 1)'],
|
||||
['ease-in', 'cubic-bezier(0.42, 0, 1, 1)'],
|
||||
['ease-in-out', 'cubic-bezier(0.42, 0, 0.58, 1)'],
|
||||
['ease-out', 'cubic-bezier(0, 0, 0.58, 1)'],
|
||||
]);
|
||||
|
||||
|
||||
export class EulerAngles {
|
||||
@@ -319,7 +317,7 @@ export const boundsForTransformedPoints = function(matrix, points, aggregateBoun
|
||||
aggregateBounds = {minX: Infinity, maxX: -Infinity, minY: Infinity, maxY: -Infinity};
|
||||
}
|
||||
if (points.length % 3) {
|
||||
console.assert('Invalid size of points array');
|
||||
console.warn('Invalid size of points array');
|
||||
}
|
||||
for (let p = 0; p < points.length; p += 3) {
|
||||
let vector = new Vector(points[p], points[p + 1], points[p + 2]);
|
||||
|
||||
Reference in New Issue
Block a user