Skip to content

Commit e78fa27

Browse files
authored
fix: prevent transpilation issues by using this to reference static props (#11088)
**Related Issue:** #10731 ## Summary Referencing the class would cause incorrect JS output in certain vite builds: **source ✅** ```ts class i { static { this.DECIMALS = 100; } static { this.SHIFT = BigInt("1" + "0".repeat(i.DECIMALS)); } } ``` **transpiled ❌** ```ts var b = class { static{this.DECIMALS = 100;} static{this.SHIFT = BigInt("1" + "0".repeat(b.DECIMALS));} // TypeError: Cannot read properties of undefined (reading 'DECIMALS') } ```
1 parent fc7b65f commit e78fa27

File tree

1 file changed

+1
-1
lines changed
  • packages/calcite-components/src/utils

1 file changed

+1
-1
lines changed

packages/calcite-components/src/utils/number.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export class BigDecimal {
1616

1717
static ROUNDED = true; // numbers are truncated (false) or rounded (true)
1818

19-
static SHIFT = BigInt("1" + "0".repeat(BigDecimal.DECIMALS)); // derived constant
19+
static SHIFT = BigInt("1" + "0".repeat(this.DECIMALS)); // derived constant
2020

2121
constructor(input: string | BigDecimal) {
2222
if (input instanceof BigDecimal) {

0 commit comments

Comments
 (0)