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

[all] Error with type only exports with TypeScript 3.8.3 #209

Closed
andrew8er opened this issue Mar 5, 2020 · 14 comments
Closed

[all] Error with type only exports with TypeScript 3.8.3 #209

andrew8er opened this issue Mar 5, 2020 · 14 comments

Comments

@andrew8er
Copy link
Contributor

andrew8er commented Mar 5, 2020

I get a lot of errors like this one with TS 3.8.3, but not with 3.8.2:

node_modules/@thi.ng/associative/index.d.ts:1:1 - error TS1383: Only named exports may use 'export type'.

1 export type * from "./api";
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~

This is related to this issue and this PR. It effectively disallows this kind of re-export. I could not find any information, whether this should actually work or not. Anyway, this is a breaking change in Typescript.

@postspectacular
Copy link
Member

hi @andrew8er - am pretty confused by this, also because we're not using namespaces and that linked issue is about export type * as X forms. But you're right, it definitely looks like a breaking change and if named exports are only supported now, then we will have to undo those changes again in this repo... 😭

Search results

@andrew8er
Copy link
Contributor Author

Yeah, it is already used pretty extensively here. I wonder if this is actually intended to work or if this was never supposed to work at all and just slipped in. I hope for the former…

@andrew8er andrew8er changed the title [all] Error with type only exports using namespaces with TypeScript 3.8.3 [all] Error with type only exports with TypeScript 3.8.3 Mar 5, 2020
@postspectacular
Copy link
Member

I just asked for some official clarification in the TS issue, let's see...

@nkint
Copy link
Contributor

nkint commented Mar 5, 2020

Hei,
I'm not sure about anything, I'm really confused too, I haven't get deep on how export type works exactly and it's not the first time that typescript teams introduced breaking changes.

But... in the last days I have updated few project to the last thi.ng umbrella version (and to the last typescript version) via yarn upgrade-interactive --latest and in the first instance everything was full of error about this.

I deleted node_modules and .cache and dist (I'm with parcel), reinstalled, restarted vscode and double checked that the vscode ts version is in sync with the workspace version and the error (by clicking in the version number in bottom right of the editor) - if you're using vscode of course.

I understand that this advice is ridiculously trivial and silly but in the end I get error to run away.

I'm not using @thi.ng/associative but I'm using other 25 packages of @thi.ng umbrella monorepo so... can you double check @andrew8er ?

The only thing broken right now is prettier that does not support import type syntax yet...

Again, sorry if this is not your situation and if this is a silly advice!

@postspectacular
Copy link
Member

postspectacular commented Mar 5, 2020

@nkint there seems to have been a change between 3.8.2 and 3.8.3. currently, the umbrella packages use 3.8.2 and i will try this all out tonight w/ the newer version...

FWIW, the import type forms can help to reduce (and in some cases already have) package sizes of dependent packages since these kind of imports only exist during compile time and will be elided from the transpiled files... but you'd only use these to import type aliases or interfaces. other constants, enums, classes, functions will have to be imported/exported normally...

@nkint
Copy link
Contributor

nkint commented Mar 5, 2020

I'm using ts 3.8.3:

  ....
  "devDependencies": {
    ...
    "typescript": "^3.8.3"
  },
  "dependencies": {
    "@thi.ng/atom": "^3.1.7",
    "@thi.ng/checks": "^2.5.3",
    "@thi.ng/equiv": "^1.0.15",
    "@thi.ng/geom": "^1.8.2",
    "@thi.ng/geom-accel": "^2.0.4",
    "@thi.ng/geom-hull": "^0.0.35",
    "@thi.ng/geom-isec": "^0.4.4",
    "@thi.ng/geom-poly-utils": "^0.1.33",
    "@thi.ng/geom-resample": "^0.2.15",
  ...

@andrew8er
Copy link
Contributor Author

andrew8er commented Mar 5, 2020

Again, sorry if this is not your situation and if this is a silly advice!

No problem, sometimes it is good to check again :)

I just tried it again and I am completely sure this error was introduced with TS 3.8.3.

@nkint
Copy link
Contributor

nkint commented Mar 5, 2020

Oh! you are right!

I see the same error but only if I open the file node_modules/@thi.ng/associative/index.d.ts.

But in my application files... no error.

Screenshot in the application, everything seems to be ok:
image

Also, the tooltip seems to correctly infer the right type...

But the error shows in if I open the index.d.ts:
image

🤔

@postspectacular
Copy link
Member

There's been some update/answer in the other issue:
microsoft/TypeScript#36966 (comment)

I will batch update all the export type occurrences and do another release asap...

@postspectacular
Copy link
Member

Oki, people - new versions of all packages are up (also built w/ 3.8.3), which hopefully fixes this (specifically via this commit), please do let me know! I've just rebuilt all examples as well and didn't run into any issues...

@postspectacular
Copy link
Member

Is this working for you now? Can this be closed? :)

@andrew8er
Copy link
Contributor Author

Sorry for the late answer, I was busy during the weekend. I can confirm, this works now 👍 .

@postspectacular
Copy link
Member

no prob, @andrew8er & thanks, as always, for reporting this! :)

@postspectacular
Copy link
Member

In case you haven't seen yet - Prettier 2.0.1 has been released over the weekend - yay!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants