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

feat: Include support for Optional Chaining #1110

Closed
1 task done
Nikodermus opened this issue Oct 8, 2019 · 9 comments
Closed
1 task done

feat: Include support for Optional Chaining #1110

Nikodermus opened this issue Oct 8, 2019 · 9 comments

Comments

@Nikodermus
Copy link

Right now Typedoc is using TS 3.5.3 and version 3.7.0 comes with major features that will probably break docs using new TS, for example I tried to use Optional Chaining and I receive the following error

Problem

Using TypeScript 3.5.3 from /home/nicolas.mahecha/vs/venue-map-component/node_modules/typedoc/node_modules/typescript/lib
Error: /home/nicolas.mahecha/vs/venue-map-component/src/VenueMap.ts(434)
 Expression expected.
Error: /home/nicolas.mahecha/vs/venue-map-component/src/VenueMap.ts(434)
 Expression expected.
Error: /home/nicolas.mahecha/vs/venue-map-component/src/VenueMap.ts(434)
 ':' expected.

For the following code which compiles correctly

const seatingCenter = isRow ? this._mapMetadata.sections[seatingId]?.rows.center : this._mapMetadata.sections[seatingId]?.center;

Suggested Solution

Updating to typescript@next should allow to start working with these new features and work off in changes for typedoc itself

Thank you guys for the awesome work, I hope to see this soon in order to start working with 3.7 features and having the documented

@Bnaya
Copy link

Bnaya commented Oct 10, 2019

I'm using yarn,
adding:

  "resolutions": {
    "typescript": "^3.7.0-dev.20191004"
  }

in the package json forces typedoc to use that version, and it works for me

@Gerrit0
Copy link
Collaborator

Gerrit0 commented Oct 12, 2019

I think TypeDoc should probably wait to upgrade to 3.7 until it releases outside of a beta branch. We still use internal compiler APIs & thus cannot guarantee that even a minor upgrade to TypeScript won't break the tool.

@zajrik
Copy link

zajrik commented Oct 13, 2019

Can confirm forcing TypeDoc to use 3.7.0-beta does work without errors when run over code using both optional chaining and null coalescence ops.

That being said, I agree that it's totally fair to wait for an official release for safety's sake. Better safe than sorry when relying on internal APIs.

@ssalka
Copy link

ssalka commented Nov 4, 2019

I think a more proper solution would be to make typescript a peer dependency of this project, and by default use whatever version the end user is working with (sorry if this has been discussed before, just found this project and looking to use it!).

@zajrik
Copy link

zajrik commented Nov 4, 2019

Agreed. I've currently resorted to adding this to my docs build workflow:

- name: Install dependencies
  run: |
    npm install

    # Replace typedoc's typescript dep with currently installed version
    # because it comes with an incompatible version
    rm -rf ./node_modules/typedoc/node_modules/typescript
    cp -r ./node_modules/typescript ./node_modules/typedoc/node_modules/typescript

which solves the problem for now. I just have to remember to do so manually when working on my theme locally if I have to make any changes to my dependencies.

@Gerrit0
Copy link
Collaborator

Gerrit0 commented Nov 4, 2019

We would like to eventually switch to a peer dependency, but this isn't possible right now because we use internal APIs that can break even at a minor update. #720, #880

@Nikodermus
Copy link
Author

Officially TS 3.7 is now the latest stable version (Including optional chaining)
https://github.com/microsoft/TypeScript/releases/tag/v3.7.2

So we can use this issue to track when we can use this features out of the box with typedoc (for them to update their version)

@Gerrit0
Copy link
Collaborator

Gerrit0 commented Nov 8, 2019

This should be fixed when #1129 is merged.

@Gerrit0
Copy link
Collaborator

Gerrit0 commented Nov 13, 2019

Version 0.15.1 is now published with support for TS 3.7 :)

@Gerrit0 Gerrit0 closed this as completed Nov 13, 2019
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

5 participants