tsdx
tsdx copied to clipboard
Type declarations don't build correctly after multiple import/exports
Current Behavior
Built type definitions dont match type definitions set in source code. Specifically I have a file that has type definitions built in:
1.src/api/data/current/get.ts
type Foo = { bar?: boolean, baz?: boolean }
const get = (params: Foo) => {
// ...
}
export default get
2.src/api/data/current/index.ts
import get from './get'
export default { get }
3.src/api/data/index.ts
import get from './current'
export default { current }
4.src/api/index.ts
import data from './data'
export default { data }
Replacing src with dist, and *.ts with *.d.ts
- get has the right types (get.d.ts)
- get has the right types (index.d.ts)
- get has the right types (data/index.d.ts)
- get has no more optional types (api/index.d.ts)
Expected behavior
Built type defs match written type defs.
Suggested solution(s)
no idea.
Additional context
I'll get this package open sourced in a bit if that helps.
Your environment
| Software | Version(s) |
|---|---|
| TSDX | 0.13.2 |
| TypeScript | 3.97 |
| Browser | irrelephant (Chrome 84.0.4147.125) |
| npm/Yarn | 1.21.1 |
| Node | 14.3.0 |
| Operating System | 10.14.6 |
This works in version 0.9.0!
So I'm not sure why this works in v0.9.0, but not v0.13.3, but TSDX doesn't do its own TS parsing, that's delegated to rollup-plugin-typescript2, so per the label, this sounds like a bug upstream there.
I checked the deps and v0.9.0 relied on rpts2 v0.21: https://github.com/formium/tsdx/blob/8e2fbf169a468fba5bff1a0a9d2f9bcc79266761/package.json#L85
It does look like there have been some changes to rpts2's type processing since then though per the Releases, but I can't tell from a glance what broke. I'd recommend checking the issues there or filing an issue there, though a lot of the issues haven't gotten responses in recent times 😕 . Which is one reason why I'm considering switching to one of the two other TS Rollup plugins, but both have had issues in the past