8000 Direct exports break lua libraries · Issue #1331 · TypeScriptToLua/TypeScriptToLua · GitHub
[go: up one dir, main page]

Skip to content

Direct exports break lua libraries #1331

New issue 8000

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
shughes-uk opened this issue Aug 17, 2022 · 1 comment
Open

Direct exports break lua libraries #1331

shughes-uk opened this issue Aug 17, 2022 · 1 comment
Labels
bug scope: transpile Any transpilation not directly related to code transforms

Comments

@shughes-uk
Copy link

Sample repo here https://github.com/shughes-uk/test

Given this is a library, I want .d.ts files emitted so it can be used by other libraries

If in main.ts I use

export { foo, bar } from "./index"
export { funcFromSubDir } from "./src/index"

the output of tstl is invalid.

I can work around this by wrapping the functions in new functions in the top level file but that's no fun.

import { foo, bar } from "./index"
import { funcFromSubDir } from "./src/index"

export const f = foo()
export const b = bar()
export const c = funcFromSubDir()
@Perryvw Perryvw added bug scope: transpile Any transpilation not directly related to code transforms labels Aug 17, 2022
@Perryvw
Copy link
Member
Perryvw commented Aug 17, 2022

Investigation result: This is default TypeScript behavior. There are some issues on their repo discussing this. It does not try to resolve declaration files referred to by your files.

In this case main.d.ts refers to the two index.d.ts files, these will not be emitted by tsc either, so we don't see the files in tstl either.

We could decide to deviate from tsc behavior and try to improve this, but it would involve either always exporting all used node_modules lua declaration files (not sure if that is desirable), or implementing some kind of dependency analysis on the declaration files we do emit, which also sounds like a pain.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug scope: transpile Any transpilation not directly related to code transforms
Projects
None yet
Development

No branches or pull requests

2 participants
0