TheDocumentation Index
Fetch the complete documentation index at: https://docs.syntblaze.com/llms.txt
Use this file to discover all available pages before exploring further.
* (asterisk) token in TypeScript serves four distinct syntactic and operational roles depending on its lexical context: a binary arithmetic operator, a generator function declarator, an iterable delegation operator, and a module namespace wildcard.
1. Arithmetic Multiplication Operator
As a binary operator,* performs mathematical multiplication. TypeScript’s static type system strictly enforces that both operands must be of type number, bigint, a numeric enum, or any. Mixing number and bigint operands without explicit casting results in a compile-time diagnostic error (specifically TS2365: Operator '*' cannot be applied to types 'number' and 'bigint').
2. Generator Function Declarator (function*)
When appended to the function keyword, * acts as a declarator that defines a generator function. This alters the function’s evaluation model, causing it to return a Generator object rather than executing immediately. In TypeScript, the resulting object is strictly typed using the built-in Generator<T, TReturn, TNext> or IterableIterator<T> interfaces.
3. Iterable Delegation Operator (yield*)
Used exclusively within the body of a generator function, the yield* expression delegates iteration control to another iterable object. TypeScript’s compiler verifies that the expression following yield* implements the Iterable<T> interface in standard generators. In asynchronous generators (async function*), the compiler also accepts and verifies against the AsyncIterable<T> interface. TypeScript automatically infers the yielded types from the delegated iterable.
4. Module Namespace Wildcard
In ES Module syntax,* functions as a wildcard identifier for namespace imports and exports. Its behavior regarding default exports depends strictly on the declaration syntax:
- Namespace Imports (
import * as Alias) and Namespace Re-exports (export * as Alias): The*token aggregates all exported members from the target module into a single namespace object. This includes the default export, which is bound to and accessible via the.defaultproperty on the alias. - Blanket Re-exports (
export * from "module"): The*token re-exports all named exports from the target module but strictly excludes the default export.
import type * as Alias), which aggregates exported types while guaranteeing the import is elided from the emitted JavaScript runtime code.
Master TypeScript with Deep Grasping Methodology!Learn More





