dsherret / ts-morph

TypeScript Compiler API wrapper for static analysis and programmatic code changes.

Home Page:https://ts-morph.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

why module name judge like this?

fantian007 opened this issue · comments

Describe the bug

Version: 21.0.1

sourceText:

declare module '@x/y' {};

judge:

const modules = sourceFile.getModules();

modules.forEach(m => {
  if (m.getName() === "'@x/y'") {
    console.log('enter');
  }
});

so, Why ? "'@x/y'" instead of '@x/y'?

And:

const t = sourceFile.getModule('@x/y'); // => undefined ?
const t = sourceFile.getModule("'@x/y'"); // => it works...

Expected behavior
'@x/y'

I'm confused...

These two module names are distinct:

declare module "example" {}
declare module example {}

That said, perhaps it should be normalizing single quotes to double quotes.