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

Upgrade to typescript v2.4 ? #99

Closed
mmc41 opened this issue Feb 24, 2017 · 18 comments · Fixed by #147
Closed

Upgrade to typescript v2.4 ? #99

mmc41 opened this issue Feb 24, 2017 · 18 comments · Fixed by #147

Comments

@mmc41
Copy link
Contributor

mmc41 commented Feb 24, 2017

I noticed that the current version of typescript-json-schema is pinned to 2.1.x versions of typescript. Can it be upgraded to the new v2.2.0?

@domoritz
Copy link
Collaborator

As long as the typescript team has not made significant changes to the internal APIs, this should be possible.

@domoritz
Copy link
Collaborator

Actually, I looked at it for a few minutes and noticed that they removed some APIs related to js docs.

> typescript-json-schema@0.9.1 build /Users/domoritz/Developer/UW/typescript-json-schema
> tsc -p .

typescript-json-schema.ts(140,31): error TS2339: Property 'getJsDocTags' does not exist on type 'Symbol'.
typescript-json-schema.ts(141,24): error TS7006: Parameter 'doc' implicitly has an 'any' type.

I don't have time to look into it right now but it should be possible to change how we get annotations and upgrade to ts 2.2.

@benbabic
Copy link
Contributor

benbabic commented Mar 17, 2017

Just as a heads up, I was looking into the changes to the compiler for ts 2.2 and it seems that ts.Symbol.members that your code references here is now a map defined as such:

 interface Symbol {
        flags: SymbolFlags;
        name: string;
        declarations?: Declaration[];
        valueDeclaration?: Declaration;
        members?: SymbolTable;
        exports?: SymbolTable;
        globalExports?: SymbolTable;
}
type SymbolTable = Map<Symbol>;

Also, I'm a bit confused by that but MDN docs for Map seem to suggest that .length is always 0 for a map and that .size is holding what would correspond to Array.length.

So clazz.members.length === 1 might not throw any error and simply be always false.

Hope this helps you move to 2.2 ...

Edit: Typo

@domoritz
Copy link
Collaborator

Thanks for the heads up @benbabic. I would have probably missed this.

The main thing I'm worried about is the changes in the API around JsDocs. I wish we could use the language service somehow instead of using compiler internal methods. However, I don't have the time to look into it at least for another month.

@mmc41
Copy link
Contributor Author

mmc41 commented Mar 19, 2017

@domoritz Has this issue been raised with the TS team - maybe they need to know there is a need to access the JsDocs API ?

@navossoc
Copy link
Contributor

@mmc41 Kinda...
Take a look at: microsoft/TypeScript#13498

@wiktor-k
Copy link

Sadly the TypeScript compiler does not support design-time decorators yet. They seem like a perfect fit for JSON Schema related annotations.

@navossoc
Copy link
Contributor

Well...

I'm using typeorm and they use reflect-metadata to extract some additional data.
So we can do fancy things like this:

import {Entity, Column, PrimaryGeneratedColumn} from "typeorm";

@Entity()
export class Photo {

    @PrimaryGeneratedColumn()
    id: number;

    @Column({
        length: 500
    })
    name: string;

    @Column("text")
    description: string;

    @Column()
    fileName: string;

    @Column("int")
    views: number;

    @Column()
    isPublished: boolean;
}

I know it will be a breaking change, but at least seems to be more "stable".
Take a look.

@domoritz
Copy link
Collaborator

Can you put this in a separate issue so we can discuss it?

@wiggisser
Copy link

What about support for 'object' type which was introduced in version 2.2

@domoritz
Copy link
Collaborator

domoritz commented Apr 7, 2017 via email

@mmc41
Copy link
Contributor Author

mmc41 commented Apr 28, 2017

FYI: In the mean time TS 2.3.1 has been released.

@domoritz domoritz changed the title Upgrade to typescript v 2.2.0 ? Upgrade to typescript v2.3 ? Apr 28, 2017
@domoritz
Copy link
Collaborator

I just updated the title of this issue ;-)

I hope to find some time to do the upgrade soon but there are a few more pressing issues that I need to get to. I'm happy to review pull requests, though!

@nfour
Copy link
Contributor

nfour commented Jun 6, 2017

@domoritz I'd be willing to contribute a PR as this is too useful and is becoming broken by random @types/* modules being imported with object etc.

Is there any info you could share on the migration process you've already accumulated? If not I understand it's just a blind debug process.

@domoritz
Copy link
Collaborator

domoritz commented Jun 6, 2017

@nfour That would be amazing! I think most of what I know is in this issue. I've also recently put a lot of effort into https://github.com/vega/typescript-to-json-schema as I was having too many problems with aliases. Maybe you find some useful things in there.

Oh, and https://astexplorer.net/ is super useful.

@nfour
Copy link
Contributor

nfour commented Jun 12, 2017

@domoritz that looks like a lot of changes, I think I'll wait until you've got that merged first 👍 . I'm getting by with --ignoreErrors for now.

@mmc41
Copy link
Contributor Author

mmc41 commented Jul 10, 2017

FYI: In the mean time TS 2.4 has been released... Updating title.

@mmc41
Copy link
Contributor Author

mmc41 commented Oct 6, 2017

@domoritz Wonderful news! Do you plan to release a new version (npm) with this soon ?

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

Successfully merging a pull request may close this issue.

7 participants