Skip to content

Error "Cannot create require path" with custom paths #694

@danielpza

Description

@danielpza

It seems tstl resolve method doesn't take into account the paths option in tsconfig.json, typescript doesn't detect any error, tstl does:

Input:

// tsconfig.json
{
  "compilerOptions": {
    "rootDir": "src",
    "outDir": "lib",
    "baseUrl": "./",
    "paths": {
      "*": ["src/scripts/*"]
    }
  },
  "tstl": {
    "luaTarget": "5.1",
    "luaLibImport": "inline"
  }
}
// src/main.ts
import { getPrefabCopy, PrefabLike } from "prefab-cache";
/// src/scripts/prefab-cache.ts
export interface PrefabLike {}
export function getPrefabCopy(prefab: string) {/*...*/}

Expected

-- lib/main.lua
require("prefab-cache")

Output

src/modmain.ts:55:43 - error TSTL0: Cannot create require path. Module does not exist within --rootDir. TypeScript path: prefab-cache.

55 import { getPrefabCopy, PrefabLike } from "prefab-cache";
                                             ~~~~~~~~~~~~~~

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