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

TypeScript 2.0 Support #234

Closed
ghost opened this issue Jun 15, 2016 · 45 comments
Closed

TypeScript 2.0 Support #234

ghost opened this issue Jun 15, 2016 · 45 comments
Labels
enhancement Improved functionality

Comments

@ghost
Copy link

ghost commented Jun 15, 2016

If I try to use typedoc with nigthly build or typescript@next, it throw this:

Error: Unknown optionstrictNullChecks.

@blakeembrey
Copy link
Member

That would be because it doesn't understand options in the nightly. If someone wants to set up infrastructure for nightly builds, we can mirror TypeScript.

@blakeembrey blakeembrey added the enhancement Improved functionality label Jun 15, 2016
@ghost
Copy link
Author

ghost commented Jun 15, 2016

Ok. I also found out that there are other new TS 2 features that isn't supported. And I think there is an bug here because my IO socket got closed again now when I tried to run the typedoc + typescript@next combo

@zhenwenc
Copy link

Is there any plan on when the new TS 2 features will be supported?

@lholznagel
Copy link

Why not wait until it's released. Currently its only a beta.

@blakeembrey blakeembrey changed the title Doesn't work with "strictNullChecks" TypeScript 2.0 Support Jul 21, 2016
@breslavsky
Copy link

Real need supporting of TS2. My be you can release beta with supporting?

@clavecoder
Copy link

As of June 30, Angular 2 is at RC4 and is already being used in production. Since Angular 2 depends on TypeScript 2.0, companies want to be able to generate source code documentation for their production software. A prerelease version of TypeDoc would be greatly appreciated.

@zakhenry
Copy link

If you want to have tsdoc work with typescript@2.0.0, try the following

"typedoc": "https://github.com/zakhenry/typedoc/releases/download/v0.4.6/typedoc-0.4.6.tgz",

Note that this is only a hack to make it output properly, it doesn't support any of the new features. I actually have to flag ignoreCompilerErrors: true, for it to run, but the output is correct despite the error output.

@DaSchTour
Copy link

Angular 2 depends on TypeScript 2.0??? Where does this come from? I'm working with TypeScript 1.8 and Angular 2 and it works finde and I can't find any reference to TypeScript 2.0
I think there is a lot of migration and bugfixing needed before TypeScript 2.0 can be use in production.

@zakhenry
Copy link

@DaSchTour yea it doesn't yet - angular core is 1.9 currently

@clavecoder
Copy link

@DaSchTour. Angular, itself, has been on the 1.9 nightly since April:
angular/angular@3412aba#diff-b9cfc7f2cdf78a7f4b91a753d10865a2R117

angular-cli master branch moved to 2.0 on July 26:
angular/angular-cli@a163186#diff-3a478e3f045d99a9448f81518886a1a1R50

One of the two major seed projects moved past 1.8 on
July 13
PatrickJS/PatrickJS-starter@8a44e2d#diff-b9cfc7f2cdf78a7f4b91a753d10865a2R128

The other is still at 1.8
https://github.com/mgechev/angular2-seed/blob/9a8bf12eef0f28d310ecc0e568f6c5235422749e/package.json#L107

So, yeah, it's time to move.

@DaSchTour
Copy link

And as you see not everybody can keep up with that pace. I'm always a friend of moving to the latest technology as fast as possible and I don't think that a seed project and the angular-cli are a good reference. And from my bit of work with typescript 2.0 I'm sure there is a lot of things to solve in the typescript compiler.
And because of the fact that typescript 2.0 has some breaking changes, I guess there are a lot of projects for example gulp-typescript, grunt-typescript and also typedoc that need to consider, that they have to run independent of the typescript version. We can't throw everybody into typescript 2.0.

@clavecoder
Copy link

clavecoder commented Jul 29, 2016

And because of the fact that typescript 2.0 has some breaking changes...

Sorry, didn't recall the breaking changes:
https://github.com/Microsoft/TypeScript/wiki/Breaking-Changes

  • No type narrowing for captured variables in functions and class expressions
  • Generic type parameters are now narrowed
  • Getters with no setters are automatically inferred to be readonly properties
  • Function declarations not allowed in blocks in strict mode

It's kind of hokey, but you could contemplate targeting different versions of TypeScript:
npm/npm#5499 (comment)

...I don't think that a seed project and the angular-cli are a good reference.

angular-cli will be the Angular Team's sanctioned project generator and, therefore, likely to be the basis for many Angular 2 projects that need documentation.

@zakhenry
Copy link

Still, given that angular has clear intentions of deprecating 1.8 support, the breaking changes are minimal enough that it should be trivial to make a package 2.x compatible.

I think for now it would be worth having a tsdoc@next branch that has compatibility with typescript@next. Like @blakeembrey mentioned at the beginning of the thread the infrastructure for nightly builds would be required to achieve this

@niieani
Copy link

niieani commented Aug 24, 2016

@zakhenry I'm still getting some errors with your version:

Error: Unknown option `lib.0`.
Error: Unknown option `lib.1`.

Note that i'm using the lib setting in tsconfig.json.

@zakhenry
Copy link

zakhenry commented Aug 24, 2016

@niieani have you tried the lastest version I'm using?https://github.com/zakhenry/typedoc/releases/download/v0.4.5/typedoc-0.4.5.tgz I realise the semver is a step backward but that's just because I re-deployed from the fork without bumping the version. Saying that I haven't encountered your issue before as I'm not using the lib setting, but this version uses a later version of TS2.0 so it may not occur.

@niieani
Copy link

niieani commented Aug 24, 2016

@zakhenry just tried it, but same problem occurs. Thanks for the quick response.

@zakhenry
Copy link

@niieani ok, that's probably because lib is a new feature and tsdoc does some kind of tsconfig.json validation. Probably a relatively easy fix, try forking from https://github.com/zakhenry/typedoc/tree/ts-2.0 as a base to get my fixes

@westy92
Copy link

westy92 commented Sep 2, 2016

TypeScript 2.0 now has a release candidate.
https://blogs.msdn.microsoft.com/typescript/2016/08/30/announcing-typescript-2-0-rc/

@bruk1977
Copy link

Any update on Typescript 2.0 support?

@aciccarello
Copy link
Collaborator

@bruk1977 There is a PR open (#290) which adds TS 2.0 support. However that PR drops support for 1.8. If you need, you can try installing that branch.

@jasonswearingen
Copy link

@blakeembrey This ticket should be reopened. #290 updates binary references, not adds ts 2 usage support

@aciccarello
Copy link
Collaborator

@jasonswearingen my understanding is that #290 added initial support for compiling with TS 2.0 (thanks to @DatenMetzgerX!). However, more PRs are needed to implement support for TS 2.0 features (see #290 comment). I suggest that these be split into separate issues.

@landonpoch
Copy link

landonpoch commented Oct 12, 2016

I tried https://github.com/zakhenry/typedoc/releases/download/v0.4.6/typedoc-0.4.6.tgz and it works. I tried https://github.com/TypeStrong/typedoc/archive/v0.5.0.tar.gz (which was the branch that got merged in recently) and it did not work.

Here's my tsconfig.json:

{
    "compilerOptions": {
        "target": "es5",
        "module": "commonjs",
        "moduleResolution": "node",
        "noImplicitAny": false,
        "removeComments": true,
        "preserveConstEnums": true
    }
}

You can see there's no new 2.0 flags in there.

Here's the error I'm seeing with the 0.5.0 release:

module.js:341
    throw err;
    ^

Error: Cannot find module '../lib/cli.js'
    at Function.Module._resolveFilename (module.js:339:15)
    at Function.Module._load (module.js:290:25)
    at Module.require (module.js:367:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/Users/landonpoch/source/csl/node_modules/typedoc/bin/typedoc:3:10)
    at Module._compile (module.js:413:34)
    at Object.Module._extensions..js (module.js:422:10)
    at Module.load (module.js:357:32)
    at Function.Module._load (module.js:314:12)
    at Function.Module.runMain (module.js:447:10)

I agree this should be reopened.

@MichaReiser
Copy link
Contributor

@landonpoch Can you be a little bit more specific... What means not working. Do you get an error message? Are you using any typedoc-plugins?

@landonpoch
Copy link

@DatenMetzgerX Updated previous message to include stack trace. I'm not using any typedoc-plugins.

@blakeembrey
Copy link
Member

It sounds like you're using it from GitHub? Did you remember to build the project?

@landonpoch
Copy link

I didn't do anything special to the project after npm install. I just have the url in my package.json. Wasn't aware that pulling if off the URL required a build first. Now that I see 0.5.0 in npm, I tested it with that and it appears to be working.

Thanks for the clarification!

@marcoturi
Copy link

Same here, after upgrading to 0.5 i still get

Error: Unknown option `lib.0`.
Error: Unknown option `lib.1`.

running:typedoc --options typedoc.json --exclude '**/*.spec.ts' ./src/
typedoc.json:

{
  "mode": "modules",
  "out": "doc",
  "theme": "default",
  "ignoreCompilerErrors": "true",
  "experimentalDecorators": "true",
  "emitDecoratorMetadata": "true",
  "target": "ES5",
  "moduleResolution": "node",
  "preserveConstEnums": "true",
  "stripInternal": "true",
  "suppressExcessPropertyErrors": "true",
  "suppressImplicitAnyIndexErrors": "true",
  "module": "commonjs"
}

@daniele-zurico
Copy link

daniele-zurico commented Oct 14, 2016

same for me... same error. Any solution on that?

  "devDependencies": {
    "typedoc": "^0.5.0"
  }

@landonpoch
Copy link

If you are getting Error: Unknown option of some sort, it means you have things in tsconfig.json that are TS 2.0 specific and not yet supported in typedoc. lib, and types are examples of this. If you remove these things it should work. I believe they are tracking specific TS 2.0 flags in separate tickets. TS 2.0 should work though as long as you aren't using any of the new TS 2.0 flags that aren't yet supported.

@emilianosantucci
Copy link
Contributor

Hi guys,
I've created on-the-fly fork (check here).

This is only a workaround that ignore paths and lib from handle as valid typescript options until typedoc can manage it.

@blakeembrey, during surfing into your code, I've found this: https://github.com/emilianosantucci/typedoc/blob/master/src/lib/utils/options/readers/arguments.ts#L28

It looks like a right approach for ignore unknown options but it seems not be implemented.
It is intentional or I'm wrong?

@blakeembrey
Copy link
Member

I'm not really sure, sorry. The code is still 99% the original owners. I'm really only the shepherd of the project with the communities help 😄 If you have a fix I'd love to have it merged.

I'd also love a great many things from this project, if someone does want to take it on in #256 - it'd be great to make it easier for people to contribute themselves, even right now it's hard for myself to navigate the codebase - it's using some unfamiliar patterns which makes it hard to improve.

@emilianosantucci
Copy link
Contributor

Okay, so we need some investigating on :).
I've created official pull request #308 to help people with TypeScrypt 2.0 to build docs without errors, check it.

About #256, I'm replying on it.

@daniele-zurico
Copy link

@emilianosantucci I installed from you fork

"devDependencies": {
    "typedoc": "git+https://github.com/emilianosantucci/typedoc.git"
  }

but same problem:

Error: Unknown option `types.0`.
Error: Unknown option `types.1`.
Error: Unknown option `types.2`.
Error: Unknown option `types.3`.
Error: Unknown option `types.4`.
Error: Unknown option `types.5`.
Error: Unknown option `types.6`.
Error: Unknown option `types.7`.
Error: Unknown option `typeRoots.0`.

@emilianosantucci
Copy link
Contributor

@daniele-zurico types and typeRoots are not ignored now, I'm going to fixing it right now.
Stay tuned ;)

@emilianosantucci
Copy link
Contributor

@daniele-zurico can you retry please?

@daniele-zurico
Copy link

@emilianosantucci

Using TypeScript 2.0.3 from /Users/danielezurico/Documents/blackswan/explore-workspace/nest-lib-dashboard-charts/node_modules/typedoc/node_modules/typescript/lib
/Users/danielezurico/Documents/blackswan/explore-workspace/nest-lib-dashboard-charts/node_modules/typedoc/lib/converter/types/reference.js:26
        return !!(type.flags & 2588672);
                      ^

TypeError: Cannot read property 'flags' of undefined

@daniele-zurico
Copy link

should be if (type && type.flag)

@emilianosantucci
Copy link
Contributor

@daniele-zurico, this seems to be another issue unlinked to my PR.
Maybe your suggestion it's correct but I don't have experience on this slice of business logic, @blakeembrey can help you (probably you need to create another issue or check if already exist).

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

No branches or pull requests