fork of hey-api/openapi-ts because I need some additional things
at feat/skip-token 35 lines 928 B view raw
1import type { Ref } from '../refs/types'; 2import type { Symbol } from '../symbols/symbol'; 3import type { SymbolKind } from '../symbols/types'; 4 5export type NameScopes = Map<string, Set<SymbolKind>>; 6 7export type Scope = { 8 /** Child scopes. */ 9 children: Array<Scope>; 10 /** Resolved names in this scope. */ 11 localNames: NameScopes; 12 /** Parent scope, if any. */ 13 parent?: Scope; 14 /** Symbols registered in this scope. */ 15 symbols: Array<Ref<Symbol>>; 16}; 17 18export type AssignOptions = { 19 /** The primary scope in which to assign a symbol's final name. */ 20 scope: Scope; 21 /** Additional scopes to update as side effects when assigning a symbol's final name. */ 22 scopesToUpdate: ReadonlyArray<Scope>; 23}; 24 25export const createScope = ( 26 args: { 27 localNames?: NameScopes; 28 parent?: Scope; 29 } = {}, 30): Scope => ({ 31 children: [], 32 localNames: args.localNames || new Map(), 33 parent: args.parent, 34 symbols: [], 35});