Skip to content

Commit 6f401e4

Browse files
authored
Refactor JavaScript reserved words list
Updated the list of JavaScript reserved words to include ECMAScript keywords, future reserved words, and removed incorrectly listed keywords.
1 parent c5f46cd commit 6f401e4

1 file changed

Lines changed: 68 additions & 36 deletions

File tree

packages/flutterjs_gen/lib/src/code_generation/expression/expression_code_generator.dart

Lines changed: 68 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -2380,75 +2380,107 @@ class ExpressionCodeGen {
23802380
// UTILITY METHODS
23812381
// =========================================================================
23822382

2383-
static const _jsReservedWords = {
2384-
'abstract',
2385-
'arguments',
2386-
'await',
2387-
'boolean',
2383+
static const _jsReservedWords = {
2384+
// ============================================================================
2385+
// ECMAScript Keywords (ALWAYS RESERVED)
2386+
// ============================================================================
23882387
'break',
2389-
'byte',
23902388
'case',
23912389
'catch',
2392-
'char',
23932390
'class',
23942391
'const',
23952392
'continue',
23962393
'debugger',
23972394
'default',
23982395
'delete',
23992396
'do',
2400-
'double',
24012397
'else',
2402-
'enum',
2403-
'eval',
24042398
'export',
24052399
'extends',
2406-
'false',
2407-
'final',
24082400
'finally',
2409-
'float',
24102401
'for',
24112402
'function',
2412-
'goto',
24132403
'if',
2414-
'implements',
24152404
'import',
24162405
'in',
24172406
'instanceof',
2418-
'int',
2419-
'interface',
2420-
'let',
2421-
'long',
2422-
'native',
24232407
'new',
2424-
'null',
2425-
'package',
2426-
'private',
2427-
'protected',
2428-
'public',
24292408
'return',
2430-
'short',
2431-
'static',
24322409
'super',
24332410
'switch',
2434-
'synchronized',
24352411
'this',
24362412
'throw',
2437-
'throws',
2438-
'transient',
2439-
'true',
24402413
'try',
24412414
'typeof',
24422415
'var',
24432416
'void',
2444-
'volatile',
24452417
'while',
24462418
'with',
24472419
'yield',
2448-
'async',
2449-
'get',
2450-
'set',
2451-
'of',
2420+
2421+
// ============================================================================
2422+
// ECMAScript Future Reserved Words (Strict Mode)
2423+
// ============================================================================
2424+
'let',
2425+
'static',
2426+
'enum',
2427+
'await',
2428+
'implements',
2429+
'interface',
2430+
'package',
2431+
'private',
2432+
'protected',
2433+
'public',
2434+
2435+
// ============================================================================
2436+
// Literals (Cannot be reassigned)
2437+
// ============================================================================
2438+
'true',
2439+
'false',
2440+
'null',
2441+
'undefined',
2442+
2443+
// ============================================================================
2444+
// Contextual Keywords (CAN be used as property names, but avoid for clarity)
2445+
// ============================================================================
2446+
'async', // Can be property: obj.async ✅
2447+
'get', // Can be property: obj.get ✅
2448+
'set', // Can be property: obj.set ✅
2449+
2450+
// ============================================================================
2451+
// REMOVED KEYWORDS (Previously incorrectly listed as reserved)
2452+
// ============================================================================
2453+
// 'of' - Only reserved in 'for...of' syntax, VALID as property name (Theme.of) ✅
2454+
// 'from' - Only reserved in import syntax, VALID as property name (Array.from) ✅
2455+
// 'target' - Never reserved, VALID as property name (event.target) ✅
2456+
// 'as' - Only reserved in TypeScript, VALID in JavaScript ✅
2457+
2458+
// ============================================================================
2459+
// Java/C-style Keywords (NOT reserved in JavaScript, but listed historically)
2460+
// These are included for compatibility with legacy transpilers
2461+
// ============================================================================
2462+
'abstract',
2463+
'boolean',
2464+
'byte',
2465+
'char',
2466+
'double',
2467+
'final',
2468+
'float',
2469+
'goto',
2470+
'int',
2471+
'long',
2472+
'native',
2473+
'short',
2474+
'synchronized',
2475+
'throws',
2476+
'transient',
2477+
'volatile',
2478+
2479+
// ============================================================================
2480+
// Special Identifiers (Avoid overriding)
2481+
// ============================================================================
2482+
'arguments', // Special object in functions
2483+
'eval', // Global function that should not be overridden
24522484
};
24532485

24542486
bool _isValidIdentifier(String name) {

0 commit comments

Comments
 (0)