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

0.19.0 broke support for typescript 3.9.7 #1362

Closed
Dergash opened this issue Sep 1, 2020 · 7 comments
Closed

0.19.0 broke support for typescript 3.9.7 #1362

Dergash opened this issue Sep 1, 2020 · 7 comments
Labels
bug Functionality does not match expectation

Comments

@Dergash
Copy link
Contributor

Dergash commented Sep 1, 2020

Recent upgrade to typescript 4.*.* in 0.19.0 broke backward-compatibility for typescript 3.9.7 due to the unchecked usage of ts.isNamedTupleMember call: e136469#diff-b580b34740b3647ff5b29f4cb299a61aR77
which results in the following output when trying to generate documentation with TS 3.9.7:

C:\projects\tesler-ui\node_modules\typedoc\dist\lib\converter\types\tuple.js:44
        return ts.isNamedTupleMember(node);
                  ^

TypeError: ts.isNamedTupleMember is not a function

I believe the change was introduced due to #1357.

Investigating further I've also found that the 0.17.0 also broke support for typescript 3.7.3 (which is version used in create-react-app
typescript template) due to the unchecked usage of ts.isIdentifierOrPrivateIdentifier: 5d41a2e#diff-560fefcd039cbf06578d6f95c3e57753R413

I've prepared a PR to restore backward compatibility.

I've also found following issues warning about not following declared peer dependency: #1240, #1257, #979

Although I'll agree that backward compatibility might be not a requirement for 0.*.* library and peer dependency are indeed warn you, broken typescript versions are pretty recent and the fix is pretty simple and non-invasive so it'll be nice to support those versions until typescript 4 stabilizes a bit so majority typedoc users may migrate to 4.*.*

Search terms

isNamedTupleMember, isIdentifierOrPrivateIdentifier, typescript 3

Expected Behavior

typedoc is backward compatible for typescript versions 3.7.3 and 3.9.7

Actual Behavior

yarn typedoc command results in the following output on the project with typescript 3.9.7:

Using TypeScript 3.9.7 from C:\projects\tesler-ui\node_modules\typescript\lib
C:\projects\tesler-ui\node_modules\typedoc\dist\lib\converter\types\tuple.js:44
        return ts.isNamedTupleMember(node);
                  ^

TypeError: ts.isNamedTupleMember is not a function

Steps to reproduce the bug

I've prepared an example project to reproduce the bug:
https://github.com/Dergash/typedoc-tamed-tuples (master branch for 3.7.3 example, 3.9.7 branch for 3.9.7)
Just clone it, yarn install, yarn typedoc and you'll receive the output

Environment

@wsz7777
Copy link

wsz7777 commented Sep 3, 2020

I miss this problem too, when I can use it with no error?

@ibwei
Copy link

ibwei commented Sep 3, 2020

I got this problem too...

@Dergash
Copy link
Contributor Author

Dergash commented Sep 3, 2020

@wsz7777 @ibwei
I now believe that it is technically not a bug but a feature request as typescript 4.0.2 is properly declared as a peer dependency.

So if this backward compatibility feature will not be merged I think the following options are available to you:

  1. Update typescript to 4.0.2 in your project to accommodate the peer dependency
  2. Use typedoc 0.18.0 as a strict dependency in your file, which supports typescript >= 3.8.3:
    your package.json:
"devDependencies": {
     "typedoc": "0.18.0"
}

or just yarn add typedoc@0.18.0
3) I've published a forked version of 0.19.0 with related fix that you can use until you find possible to upgrade typescript:

"devDependencies": {
     "@tesler-ui/typedoc": "0.19.0-typescript-3"
}

or just

yarn remove typedoc
yarn add @tesler-ui/typedoc

or you could fork yourself and implement changes and fix yourself using linked PR as a reference.

@wsz7777
Copy link

wsz7777 commented Sep 4, 2020

thank you ,in my project use typescript around packages with @4.x can solve this problem.

"typescript": "^4.0.2",
"jest": "^26.4.2",
"ts-jest": "^26.3.0",
"@types/jest": "^26.0.13",
"@typescript-eslint/eslint-plugin": "^4.0.1",
"@typescript-eslint/parser": "^4.0.1",

@ibwei
Copy link

ibwei commented Sep 4, 2020

@wsz7777 @ibwei
I now believe that it is technically not a bug but a feature request as typescript 4.0.2 is properly declared as a peer dependency.

So if this backward compatibility feature will not be merged I think the following options are available to you:

  1. Update typescript to 4.0.2 in your project to accommodate the peer dependency
  2. Use typedoc 0.18.0 as a strict dependency in your file, which supports typescript >= 3.8.3:
    your package.json:
"devDependencies": {
     "typedoc": "0.18.0"
}

or just yarn add typedoc@0.18.0
3) I've published a forked version of 0.19.0 with related fix that you can use until you find possible to upgrade typescript:

"devDependencies": {
     "@tesler-ui/typedoc": "0.19.0-typescript-3"
}

or just

yarn remove typedoc
yarn add @tesler-ui/typedoc

or you could fork yourself and implement changes and fix yourself using linked PR as a reference.

thank you very much. I updated my typescript version according to your instructions, and the problem was solved.

@Gerrit0 Gerrit0 closed this as completed in 833ebb8 Sep 5, 2020
@Gerrit0
Copy link
Collaborator

Gerrit0 commented Sep 5, 2020

As discussed a bit in #1361, supporting old versions of TypeScript isn't really what I'd like to focus the time I have for this project on. typedoc@0.19.1 reintroduces support for typescript@3.9 thanks to @Dergash, and I think supporting one minor version older than the current version is feasible, so will try to do that... If you're still on an older version of TypeScript than that, upgrade!

@thekennysong
Copy link

As what others said I upgraded to "typescript": "^4.0.2" and it works great now. Thanks all!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Functionality does not match expectation
Projects
None yet
Development

No branches or pull requests

5 participants