mirror of
https://github.com/angular/angular
synced 2026-05-24 09:28:37 +00:00
Mutable exports, i.e. using this pattern
```
export let x = 0;
export function f() {
x += 1;
}
```
is problematic to transpile to CommonJS and Goog.module systems, we are
working on banning it google internal codebase.
The workaround is adding an explcit getter function.
PR Close #32425
50 lines
1.2 KiB
TypeScript
50 lines
1.2 KiB
TypeScript
/**
|
|
* @license
|
|
* Copyright Google Inc. All Rights Reserved.
|
|
*
|
|
* Use of this source code is governed by an MIT-style license that can be
|
|
* found in the LICENSE file at https://angular.io/license
|
|
*/
|
|
|
|
import {getIntParameter} from '../util';
|
|
|
|
export class TableCell {
|
|
constructor(public row: number, public col: number, public value: string) {}
|
|
}
|
|
|
|
let tableCreateCount: number;
|
|
let maxRow: number;
|
|
let maxCol: number;
|
|
let numberData: TableCell[][];
|
|
let charData: TableCell[][];
|
|
|
|
init();
|
|
|
|
function init() {
|
|
maxRow = getIntParameter('rows');
|
|
maxCol = getIntParameter('cols');
|
|
tableCreateCount = 0;
|
|
numberData = [];
|
|
charData = [];
|
|
for (let r = 0; r <= maxRow; r++) {
|
|
const numberRow: TableCell[] = [];
|
|
numberData.push(numberRow);
|
|
const charRow: TableCell[] = [];
|
|
charData.push(charRow);
|
|
for (let c = 0; c <= maxCol; c++) {
|
|
numberRow.push(new TableCell(r, c, `${c}/${r}`));
|
|
charRow.push(new TableCell(r, c, `${charValue(c)}/${charValue(r)}`));
|
|
}
|
|
}
|
|
}
|
|
|
|
function charValue(i: number): string {
|
|
return String.fromCharCode('A'.charCodeAt(0) + (i % 26));
|
|
}
|
|
|
|
export const emptyTable: TableCell[][] = [];
|
|
|
|
export function buildTable(): TableCell[][] {
|
|
tableCreateCount++;
|
|
return tableCreateCount % 2 ? numberData : charData;
|
|
}
|