Skip to content

Compiler API to resolve path from ImportDeclaration #28276

Open
@longlho

Description

@longlho

Hi there, since TS supports paths in tsconfig.json, is there an API in the compiler (Program, CompilerHost or something) to programmatically resolve real path of an import?

I wrote this transformer https://github.com/longlho/ts-transform-css-modules and it's tripping up on paths that are aliased in tsconfig.json, e.g:

import * as css from 'alias/foo.css'

tsconfig.json

{
  "compilerOptions": {
    "paths": {
      "alias/*": "../../../some_location/*"
    }
  }
}

I can try to manually reconstruct TS resolver but rather not to.

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    APIRelates to the public API for TypeScriptIn DiscussionNot yet reached consensusSuggestionAn idea for TypeScript

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions