Skip to content

Incorrect symbol resolution for property shorthand in decorators (e.g. { imports } in NestJS modules) #415

Open
@ofeki-neosec

Description

@ofeki-neosec

When using TypeScript property shorthand (e.g. { imports }) in an object literal that matches a known property on a decorator (such as the imports property of NestJS @Module), scip-typescript resolves the property to the builtin symbol (e.g. ModuleMetadata#imports) instead of the local identifier (e.g. the value imported from './modules').

Example:

import { Module } from '@nestjs/common';
import { imports } from './modules';

@Module({
  controllers: [],
  imports,        // property shorthand
  providers: []
})
export class AppModule {}

In this example, the imports property is resolved to the built-in ModuleMetadata#imports instead of the local imports identifier.

[relative_path: "src/app/app.module.ts"
 occurrences {
   range: 0
   range: 0
   range: 0
   symbol: "scip-typescript npm minimal-indexing-env 1.0.0 src/app/`app.module.ts`/"
   symbol_roles: 1
   enclosing_range: 0
   enclosing_range: 0
   enclosing_range: 8
   enclosing_range: 0
 }
 occurrences {
   range: 0
   range: 9
   range: 15
   symbol: "scip-typescript npm @nestjs/common 9.4.3 decorators/modules/`module.decorator.d.ts`/Module()."
 }
 occurrences {
   range: 0
   range: 23
   range: 39
   symbol: "scip-typescript npm @nestjs/common 9.4.3 `index.d.ts`/"
 }
 occurrences {
   range: 1
   range: 9
   range: 16
   symbol: "scip-typescript npm minimal-indexing-env 1.0.0 src/app/modules/`index.ts`/imports."
 }
 occurrences {
   range: 1
   range: 24
   range: 35
   symbol: "scip-typescript npm minimal-indexing-env 1.0.0 src/app/modules/`index.ts`/"
 }
 occurrences {
   range: 2
   range: 1
   range: 7
   symbol: "scip-typescript npm @nestjs/common 9.4.3 decorators/modules/`module.decorator.d.ts`/Module()."
 }
 occurrences {
   range: 3
   range: 2
   range: 13
   symbol: "scip-typescript npm @nestjs/common 9.4.3 interfaces/modules/`module-metadata.interface.d.ts`/ModuleMetadata#controllers."
 }
 occurrences {
   range: 4
   range: 2
   range: 9
   symbol: "scip-typescript npm @nestjs/common 9.4.3 interfaces/modules/`module-metadata.interface.d.ts`/ModuleMetadata#imports."
 }
 occurrences {
   range: 5
   range: 2
   range: 11
   symbol: "scip-typescript npm @nestjs/common 9.4.3 interfaces/modules/`module-metadata.interface.d.ts`/ModuleMetadata#providers."
 }
 occurrences {
   range: 7
   range: 13
   range: 22
   symbol: "scip-typescript npm minimal-indexing-env 1.0.0 src/app/`app.module.ts`/AppModule#"
   symbol_roles: 1
   enclosing_range: 2
   enclosing_range: 0
   enclosing_range: 7
   enclosing_range: 25
 }
 symbols {
   symbol: "scip-typescript npm minimal-indexing-env 1.0.0 src/app/`app.module.ts`/"
   documentation: "```ts\nmodule \"app.module.ts\"\n```"
 }
 symbols {
   symbol: "scip-typescript npm minimal-indexing-env 1.0.0 src/app/`app.module.ts`/AppModule#"
   documentation: "```ts\nclass AppModule\n```"
 }]

Expected behavior - The symbol for the value of the imports property should be resolved to the local identifier (./modules#imports), not the property defined in the decorator's interface.

This causes loss of correct symbol connectivity and reference tracking between modules in larger codebases (e.g., monorepos).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions