mirror of
https://github.com/Smaug123/KaTeX
synced 2025-10-07 20:28:38 +00:00
Port spacingData and unicodeSymbols to @flow. (#1195)
* Port spacingData and unicodeSymbols to @flow. * Review fixes. * Made Measurement an exact object type.
This commit is contained in:
committed by
Kevin Barabash
parent
96ad6e0f4f
commit
0ce53e7631
@@ -1,22 +1,40 @@
|
|||||||
|
// @flow
|
||||||
/**
|
/**
|
||||||
* Describes spaces between different classes of atoms.
|
* Describes spaces between different classes of atoms.
|
||||||
*/
|
*/
|
||||||
|
import type {Measurement} from "./units";
|
||||||
|
|
||||||
const thinspace = {
|
const thinspace: Measurement = {
|
||||||
number: 3,
|
number: 3,
|
||||||
unit: "mu",
|
unit: "mu",
|
||||||
};
|
};
|
||||||
const mediumspace = {
|
const mediumspace: Measurement = {
|
||||||
number: 4,
|
number: 4,
|
||||||
unit: "mu",
|
unit: "mu",
|
||||||
};
|
};
|
||||||
const thickspace = {
|
const thickspace: Measurement = {
|
||||||
number: 5,
|
number: 5,
|
||||||
unit: "mu",
|
unit: "mu",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Making the type below exact with all optional fields doesn't work due to
|
||||||
|
// - https://github.com/facebook/flow/issues/4582
|
||||||
|
// - https://github.com/facebook/flow/issues/5688
|
||||||
|
// However, since *all* fields are optional, $Shape<> works as suggested in 5688
|
||||||
|
// above.
|
||||||
|
export type Spacings = $Shape<{
|
||||||
|
mord: Measurement,
|
||||||
|
mop: Measurement,
|
||||||
|
mbin: Measurement,
|
||||||
|
mrel: Measurement,
|
||||||
|
mopen: Measurement,
|
||||||
|
mclose: Measurement,
|
||||||
|
mpunct: Measurement,
|
||||||
|
minner: Measurement,
|
||||||
|
}> & {};
|
||||||
|
|
||||||
// Spacing relationships for display and text styles
|
// Spacing relationships for display and text styles
|
||||||
export const spacings = {
|
export const spacings: {[$Keys<Spacings>]: Spacings} = {
|
||||||
mord: {
|
mord: {
|
||||||
mop: thinspace,
|
mop: thinspace,
|
||||||
mbin: mediumspace,
|
mbin: mediumspace,
|
||||||
@@ -69,7 +87,7 @@ export const spacings = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Spacing relationships for script and scriptscript styles
|
// Spacing relationships for script and scriptscript styles
|
||||||
export const tightSpacings = {
|
export const tightSpacings: {[$Keys<Spacings>]: Spacings} = {
|
||||||
mord: {
|
mord: {
|
||||||
mop: thinspace,
|
mop: thinspace,
|
||||||
},
|
},
|
||||||
|
@@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
const accents = require('./unicodeAccents');
|
const accents = require('./unicodeAccents');
|
||||||
|
|
||||||
|
console.log("// @flow");
|
||||||
console.log("// This file is GENERATED by unicodeMake.js. DO NOT MODIFY.");
|
console.log("// This file is GENERATED by unicodeMake.js. DO NOT MODIFY.");
|
||||||
console.log("");
|
console.log("");
|
||||||
|
|
||||||
|
@@ -1,3 +1,4 @@
|
|||||||
|
// @flow
|
||||||
// This file is GENERATED by unicodeMake.js. DO NOT MODIFY.
|
// This file is GENERATED by unicodeMake.js. DO NOT MODIFY.
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
@@ -37,7 +37,7 @@ const relativeUnit = {
|
|||||||
"mu": true,
|
"mu": true,
|
||||||
};
|
};
|
||||||
|
|
||||||
export type Measurement = {number: number, unit: string};
|
export type Measurement = {| number: number, unit: string |};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine whether the specified unit (either a string defining the unit
|
* Determine whether the specified unit (either a string defining the unit
|
||||||
|
Reference in New Issue
Block a user