Skip to content
New issue

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

Type declarations don't build correctly after multiple import/exports #796

Open
jdetle opened this issue Aug 13, 2020 · 2 comments
Open
Labels
kind: bug Something isn't working scope: upstream Issue in upstream dependency topic: rollup-plugin-typescript2 Issues and PRs relating to rpts2

Comments

@jdetle
Copy link

jdetle commented Aug 13, 2020

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

  1. get has the right types (get.d.ts)
  2. get has the right types (index.d.ts)
  3. get has the right types (data/index.d.ts)
  4. 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
@agilgur5 agilgur5 added kind: bug Something isn't working scope: upstream Issue in upstream dependency labels Aug 13, 2020
@jdetle
Copy link
Author

jdetle commented Aug 14, 2020

This works in version 0.9.0!

@agilgur5 agilgur5 changed the title Type definitions dont seem to build appropriately Type declarations don't build correctly after multiple import/exports Oct 3, 2020
@agilgur5
Copy link
Collaborator

agilgur5 commented Oct 3, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: bug Something isn't working scope: upstream Issue in upstream dependency topic: rollup-plugin-typescript2 Issues and PRs relating to rpts2
Projects
None yet
Development

No branches or pull requests

2 participants