diff --git a/CHANGES.md b/CHANGES.md
index 6b1a4c2939..c6d07459bc 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -12,6 +12,7 @@ Parser:
Grammars:
+- fix(js/ts) `Float32Array` highlighted incorrectly (#3353) [Josh Goebel][]
- fix(css) single-colon psuedo-elements no longer break highlighting (#3240) [Josh Goebel][]
- fix(scss) single-colon psuedo-elements no longer break highlighting (#3240) [Josh Goebel][]
- enh(fsharp) rewrite most of the grammar, with many improvements [Melvyn Laïly][]
diff --git a/src/languages/javascript.js b/src/languages/javascript.js
index 1ad7391950..6dc7bd521b 100644
--- a/src/languages/javascript.js
+++ b/src/languages/javascript.js
@@ -254,7 +254,17 @@ export default function(hljs) {
const CLASS_REFERENCE = {
relevance: 0,
- match: /\b[A-Z][a-z]+([A-Z][a-z]+)*/,
+ match:
+ regex.either(
+ // Hard coded exceptions
+ /\bJSON/,
+ // Float32Array
+ /\b[A-Z][a-z]+([A-Z][a-z]+|\d)*/,
+ // CSSFactory
+ /\b[A-Z]{2,}([A-Z][a-z]+|\d)+/,
+ // BLAH
+ // this will be flagged as a UPPER_CASE_CONSTANT instead
+ ),
className: "title.class",
keywords: {
_: [
diff --git a/src/languages/lib/ecmascript.js b/src/languages/lib/ecmascript.js
index 965af40f71..e1a2218378 100644
--- a/src/languages/lib/ecmascript.js
+++ b/src/languages/lib/ecmascript.js
@@ -51,44 +51,61 @@ const LITERALS = [
"Infinity"
];
+// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects
export const TYPES = [
- "Intl",
- "DataView",
- "Number",
- "Math",
- "Date",
- "String",
- "RegExp",
+ // Fundamental objects
"Object",
"Function",
"Boolean",
- "Error",
"Symbol",
- "Set",
- "Map",
- "WeakSet",
- "WeakMap",
- "Proxy",
- "Reflect",
- "JSON",
- "Promise",
+ // numbers and dates
+ "Math",
+ "Date",
+ "Number",
+ "BigInt",
+ // text
+ "String",
+ "RegExp",
+ // Indexed collections
+ "Array",
+ "Float32Array",
"Float64Array",
+ "Int8Array",
+ "Uint8Array",
+ "Uint8ClampedArray",
"Int16Array",
"Int32Array",
- "Int8Array",
"Uint16Array",
"Uint32Array",
- "Float32Array",
- "Array",
- "Uint8Array",
- "Uint8ClampedArray",
- "ArrayBuffer",
"BigInt64Array",
"BigUint64Array",
- "BigInt"
+ // Keyed collections
+ "Set",
+ "Map",
+ "WeakSet",
+ "WeakMap",
+ // Structured data
+ "ArrayBuffer",
+ "SharedArrayBuffer",
+ "Atomics",
+ "DataView",
+ "JSON",
+ // Control abstraction objects
+ "Promise",
+ "Generator",
+ "GeneratorFunction",
+ "AsyncFunction",
+ // Reflection
+ "Reflect",
+ "Proxy",
+ // Internationalization
+ "Intl",
+ // WebAssembly
+ "WebAssembly"
];
export const ERROR_TYPES = [
+ "Error",
"EvalError",
"InternalError",
"RangeError",
diff --git a/test/markup/javascript/class.expect.txt b/test/markup/javascript/class.expect.txt
index 3096980ec4..3ef253c364 100644
--- a/test/markup/javascript/class.expect.txt
+++ b/test/markup/javascript/class.expect.txt
@@ -26,3 +26,10 @@
if(value) {}
switch(value) {}
try {} catch(err) {}
+
+Car
+Vehicle
+SelfDrivingTruck
+CSSParser
+Float32Array
+BigInt64Array
diff --git a/test/markup/javascript/class.txt b/test/markup/javascript/class.txt
index 0ba06eab72..bebfe77f90 100644
--- a/test/markup/javascript/class.txt
+++ b/test/markup/javascript/class.txt
@@ -26,3 +26,10 @@ while(value) {}
if(value) {}
switch(value) {}
try {} catch(err) {}
+
+Car
+Vehicle
+SelfDrivingTruck
+CSSParser
+Float32Array
+BigInt64Array