Skip to content

typescript-rtti/rtti-testcase-98

Repository files navigation

Repro repository: https://github.com/aquilae/typescript-rtti-relative-path-issue

Doing reflect<T>() where T is imported from a referenced composite project emits incorrect relative path to T source from importing module:

/* folder structure:
- packages // src dir
 - export
 - import
- .typescript // out dir
 - packages
  - export
  - import
*/

// Importing.ts
import { reflect } from 'typescript-rtti'
import type Exported from '../export/Exported'

reflect<Exported>()

// Importing.js
{ : function (t) { return require("../../.typescript/packages/export/Exported")["default"]; } }
//                                        ^ we're already in .typescript folder here
...

From what little investigation I could do, tsc treats composite projects as external modules, and the source file of symbol for Exported is .d.ts file from the export project out dir, not the source Exported.ts.

That confuses RTTI which seemingly treats everything not under node_modules as "internal" files that don't move relative to each other.