Home / File/ Keyword.ts — react Source File

Keyword.ts — react Source File

Architecture documentation for Keyword.ts, a typescript file in the react codebase. 0 imports, 1 dependents.

File typescript CompilerCore BabelIntegration 1 dependents 1 functions

Entity Profile

Dependency Diagram

graph LR
  02daee7e_ccf7_0a94_14f1_503a29b722a4["Keyword.ts"]
  a451512c_09d1_62a9_9849_56979af31473["HIR.ts"]
  a451512c_09d1_62a9_9849_56979af31473 --> 02daee7e_ccf7_0a94_14f1_503a29b722a4
  style 02daee7e_ccf7_0a94_14f1_503a29b722a4 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

/**
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

/**
 * https://tc39.es/ecma262/multipage/ecmascript-language-lexical-grammar.html#sec-keywords-and-reserved-words
 */

/**
 * Note: `await` and `yield` are contextually allowed as identifiers.
 *   await: reserved inside async functions and modules
 *   yield: reserved inside generator functions
 *
 * Note: `async` is not reserved.
 */
const RESERVED_WORDS = new Set([
  'break',
  'case',
  'catch',
  'class',
  'const',
  'continue',
  'debugger',
  'default',
  'delete',
  'do',
  'else',
  'enum',
  'export',
  'extends',
  'false',
  'finally',
  'for',
  'function',
  'if',
  'import',
  'in',
  'instanceof',
  'new',
  'null',
  'return',
  'super',
  'switch',
  'this',
  'throw',
  'true',
  'try',
  'typeof',
  'var',
  'void',
  'while',
  'with',
]);

/**
 * Reserved when a module has a 'use strict' directive.
 */
const STRICT_MODE_RESERVED_WORDS = new Set([
  'let',
  'static',
  'implements',
  'interface',
  'package',
  'private',
  'protected',
  'public',
]);
/**
 * The names arguments and eval are not keywords, but they are subject to some restrictions in
 * strict mode code.
 */
const STRICT_MODE_RESTRICTED_WORDS = new Set(['eval', 'arguments']);

/**
 * Conservative check for whether an identifer name is reserved or not. We assume that code is
 * written with strict mode.
 */
export function isReservedWord(identifierName: string): boolean {
  return (
    RESERVED_WORDS.has(identifierName) ||
    STRICT_MODE_RESERVED_WORDS.has(identifierName) ||
    STRICT_MODE_RESTRICTED_WORDS.has(identifierName)
  );
}

Domain

Subdomains

Functions

Frequently Asked Questions

What does Keyword.ts do?
Keyword.ts is a source file in the react codebase, written in typescript. It belongs to the CompilerCore domain, BabelIntegration subdomain.
What functions are defined in Keyword.ts?
Keyword.ts defines 1 function(s): isReservedWord.
What files import Keyword.ts?
Keyword.ts is imported by 1 file(s): HIR.ts.
Where is Keyword.ts in the architecture?
Keyword.ts is located at compiler/packages/babel-plugin-react-compiler/src/Utils/Keyword.ts (domain: CompilerCore, subdomain: BabelIntegration, directory: compiler/packages/babel-plugin-react-compiler/src/Utils).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free