Skip to content

Commit f879697

Browse files
committed
Fix Flow errors and revert upgrade
1 parent 1b77bf4 commit f879697

File tree

4 files changed

+17
-10
lines changed

4 files changed

+17
-10
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
"babel-jest": "^26.6.3",
7575
"babel-plugin-macros": "^3.0.1",
7676
"codegen.macro": "^4.1.0",
77-
"flow-bin": "^0.145.0",
77+
"flow-bin": "0.123.0",
7878
"globby": "^11.0.2",
7979
"husky": "^4.2.5",
8080
"jest": "^26.6.3",

src/components/Highlight.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class Highlight extends Component<Props, *> {
3131
prevLanguage: Language | void;
3232
themeDict: ThemeDict | void;
3333

34-
getThemeDict = (props: Props) => {
34+
getThemeDict = (props: Props): ThemeDict | void => {
3535
if (
3636
this.themeDict !== undefined &&
3737
props.theme === this.prevTheme &&
@@ -128,21 +128,26 @@ class Highlight extends Component<Props, *> {
128128
code: string,
129129
grammar: PrismGrammar,
130130
language: Language
131-
): Array<PrismToken> => {
131+
): Array<PrismToken | string> => {
132132
const env = {
133133
code,
134134
grammar,
135135
language,
136+
tokens: [],
136137
};
137138

138139
Prism.hooks.run("before-tokenize", env);
139-
env.tokens = Prism.tokenize(env.code, env.grammar, env.language);
140+
const tokens = (env.tokens = Prism.tokenize(
141+
env.code,
142+
env.grammar,
143+
env.language
144+
));
140145
Prism.hooks.run("after-tokenize", env);
141146

142-
return env.tokens;
147+
return tokens;
143148
};
144149

145-
render() {
150+
render(): Node {
146151
const { Prism, language, code, children } = this.props;
147152

148153
const themeDict = this.getThemeDict(this.props);

src/vendor/prism/prism-core.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,9 @@ var Prism = (function () {
184184
grammar: grammar,
185185
language: language,
186186
};
187+
_.hooks.run("before-tokenize", env);
187188
env.tokens = _.tokenize(env.code, env.grammar);
189+
_.hooks.run("after-tokenize", env);
188190
return Token.stringify(_.util.encode(env.tokens), env.language);
189191
},
190192

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2465,10 +2465,10 @@ find-versions@^4.0.0:
24652465
dependencies:
24662466
semver-regex "^3.1.2"
24672467

2468-
flow-bin@^0.145.0:
2469-
version "0.145.0"
2470-
resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.145.0.tgz#922f7c3568caaa5eb64621ec536deb56b24d1795"
2471-
integrity sha512-+9fi9BMxRBtSWC1x0hWggWTb8Vih+AC7wyvLAX5wR1m6u2lF2HLtixXqy2GX8bWgaynSEJR5lmPxYYC4wMI8cA==
2468+
flow-bin@0.123.0:
2469+
version "0.123.0"
2470+
resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.123.0.tgz#7ba61a0b8775928cf4943ccf78eed2b1b05f7b3a"
2471+
integrity sha512-Ylcf8YDIM/KrqtxkPuq+f8O+6sdYA2Nuz5f+sWHlp539DatZz3YMcsO1EiXaf1C11HJgpT/3YGYe7xZ9/UZmvQ==
24722472

24732473
for-in@^1.0.2:
24742474
version "1.0.2"

0 commit comments

Comments
 (0)