Skip to content

add processing imported ratelimit configs#8

Merged
m2broth merged 5 commits into
masterfrom
feat/add_processing_imported_ratelimit_configs
Aug 22, 2025
Merged

add processing imported ratelimit configs#8
m2broth merged 5 commits into
masterfrom
feat/add_processing_imported_ratelimit_configs

Conversation

@m2broth
Copy link
Copy Markdown
Collaborator

@m2broth m2broth commented Aug 12, 2025

Summary
Enhance initializer resolver to evaluate decorator arguments passed as named-imported consts by following import aliases to their exported declarations.
Simplify supported expression kinds and align fixtures/tests with the intended scope.

Motivation
Previously, when a decorator argument was a named import, the resolver saw only the alias symbol at the call site and failed to resolve it to the exported declaration.

This broke cases like:

import { userIpRateLimitConfigExpr } from './rateLimitConfigs'

@RateLimitByUserIp(userIpRateLimitConfigExpr)

What's Changed

  • Added alias resolution for ImportSpecifier:
  • Introduced getImportSpecifierValue(importSpecifier, typeChecker).
  • Uses typeChecker.getAliasedSymbol to find the exported declaration and evaluate its initializer.
  • Correctly computes expressions like 15 * 60 in configs:
    export const rateLimitConfig = { limit: 100, slidingWindowSec: 15 * 60, }

@m2broth m2broth marked this pull request as ready for review August 12, 2025 10:07
@m2broth m2broth merged commit 9348295 into master Aug 22, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants