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 TypeScript dependency to 2.7.2 #583

Closed
mertdeg2 opened this issue Apr 27, 2018 · 9 comments
Closed

Upgrade TypeScript dependency to 2.7.2 #583

mertdeg2 opened this issue Apr 27, 2018 · 9 comments

Comments

@mertdeg2
Copy link

https://github.com/mgechev/codelyzer/blob/4.3.0/package.json#L69

We couldn't use codelyzer because its pinning TS 2.4

@mgechev
Copy link
Owner

mgechev commented Apr 27, 2018

How is the dev dependency preventing you from using the tool?

@mertdeg2
Copy link
Author

mertdeg2 commented Apr 27, 2018

At Google, its a standard practice to import TS sources for NPM modules. But we can only have one copy of TypeScript NPM module.

When I tried to build codelyzer from its sources, these are the errors I got (because codelyzer is depending on old TS version):

/node_modules/codelyzer/src/angular/metadataReader.ts(40,7): error TS2349: Cannot invoke an expression whose type lacks a call signature. Type '(<U>(callbackfn: (value: Decorator, index: number, array: ReadonlyArray<Decorator>) => U, thisArg...' has no compatible call signatures.

 40       (d.decorators || ([] as ts.Decorator[])).map((dec: ts.Decorator) => {
          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 41         return Maybe.lift(dec)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
... 
 44           .fmap(() => this.readComponentMetadata(d, dec));
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 45       })
    ~~~~~~~~

/node_modules/codelyzer/src/angular/metadataReader.ts(49,7): error TS2349: Cannot invoke an expression whose type lacks a call signature. Type '(<U>(callbackfn: (value: Decorator, index: number, array: ReadonlyArray<Decorator>) => U, thisArg...' has no compatible call signatures.

 49       (d.decorators || ([] as ts.Decorator[])).map((dec: ts.Decorator) =>
          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 50         Maybe.lift(dec)
    ~~~~~~~~~~~~~~~~~~~~~~~
... 
 53           .fmap(() => this.readDirectiveMetadata(d, dec))
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 54       )
    ~~~~~~~

/node_modules/codelyzer/src/angular/metadataReader.ts(57,5): error TS2322: Type '{}' is not assignable to type 'DirectiveMetadata'.
  Property 'selector' is missing in type '{}'.

57     return directiveMetadata || componentMetadata || undefined;
       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

/node_modules/codelyzer/src/angular/metadataReader.ts(62,66): error TS2345: Argument of type 'NodeArray<ObjectLiteralElementLike>' is not assignable to parameter of type 'ObjectLiteralElement[]'.
  Property 'push' is missing in type 'NodeArray<ObjectLiteralElementLike>'.

62       .bind(expr => getStringInitializerFromProperty('selector', expr.properties))
                                                                    ~~~~~~~~~~~~~~~

/node_modules/codelyzer/src/angular/metadataReader.ts(63,40): error TS2339: Property 'text' does not exist on type '{}'.

63       .fmap(initializer => initializer.text);
                                          ~~~~

/node_modules/codelyzer/src/angular/ngWalker.ts(62,6): error TS2352: Type 'NodeArray<Decorator>' cannot be converted to type 'Decorator[]'.

62     (<ts.Decorator[]>declaration.decorators || []).forEach(this.visitClassDecorator.bind(this));
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

/node_modules/codelyzer/src/angular/ngWalker.ts(62,6): error TS2352: Type 'NodeArray<Decorator>' cannot be converted to type 'Decorator[]'.
  Property 'push' is missing in type 'NodeArray<Decorator>'.

62     (<ts.Decorator[]>declaration.decorators || []).forEach(this.visitClassDecorator.bind(this));
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

/node_modules/codelyzer/src/angular/ngWalker.ts(67,6): error TS2352: Type 'NodeArray<Decorator>' cannot be converted to type 'Decorator[]'.

67     (<ts.Decorator[]>method.decorators || []).forEach(this.visitMethodDecorator.bind(this));
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

/node_modules/codelyzer/src/angular/ngWalker.ts(72,6): error TS2352: Type 'NodeArray<Decorator>' cannot be converted to type 'Decorator[]'.

72     (<ts.Decorator[]>prop.decorators || []).forEach(this.visitPropertyDecorator.bind(this));
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

/node_modules/codelyzer/src/propertyDecoratorBase.ts(39,6): error TS2352: Type 'NodeArray<Decorator>' cannot be converted to type 'Decorator[]'.

39     (<ts.Decorator[]>node.decorators || []).forEach(this.validateDecorator.bind(this, node.name.text));
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

/node_modules/codelyzer/src/selectorNameBase.ts(106,6): error TS2352: Type 'NodeArray<Decorator>' cannot be converted to type 'Decorator[]'.

106     (<ts.Decorator[]>node.decorators || []).forEach(this.validateDecorator.bind(this, node.name.text));
         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

/node_modules/codelyzer/src/usePipeDecoratorRule.ts(35,24): error TS2352: Type 'NodeArray<Decorator>' cannot be converted to type 'any[]'.

35       let decorators = <any[]>node.decorators || [];
                          ~~~~~~~~~~~~~~~~~~~~~~

/node_modules/codelyzer/src/usePipeDecoratorRule.ts(35,24): error TS2352: Type 'NodeArray<Decorator>' cannot be converted to type 'any[]'.
  Property 'push' is missing in type 'NodeArray<Decorator>'.

35       let decorators = <any[]>node.decorators || [];
                          ~~~~~~~~~~~~~~~~~~~~~~

/node_modules/codelyzer/src/util/ngQuery.ts(21,53): error TS2345: Argument of type 'NodeArray<ObjectLiteralElementLike>' is not assignable to parameter of type 'ObjectLiteralElement[]'.

21     getStringInitializerFromProperty('templateUrl', expr.properties)
                                                       ~~~~~~~~~~~~~~~

/node_modules/codelyzer/src/util/ngQuery.ts(26,121): error TS2345: Argument of type 'NodeArray<ObjectLiteralElementLike>' is not assignable to parameter of type 'ObjectLiteralElement[]'.

26   return decoratorArgument(dec).bind((expr: ts.ObjectLiteralExpression) => getStringInitializerFromProperty('template', expr.properties));
                                                                                                                           ~~~~~~~~~~~~~~~

/node_modules/codelyzer/src/util/utils.ts(47,11): error TS2352: Type 'NodeArray<Decorator>' cannot be converted to type 'Decorator[]'.

47   return (<ts.Decorator[]>declaration.decorators || [])
             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

@mertdeg2
Copy link
Author

I would be happy to upgrade codelyzer to TS 2.7.2, but I might have noob questions.

For example: how do I run codelyzer tests?

@mgechev
Copy link
Owner

mgechev commented Apr 27, 2018

I'll take a look at this today.

@mertdeg2
Copy link
Author

Sounds good. Thanks Minko! Let me know if i can help.

@mgechev
Copy link
Owner

mgechev commented Apr 27, 2018

@mertdeg2 would you try the branch minko/dev-typescript. It should work properly with the latest TypeScript.

@mertdeg2
Copy link
Author

mertdeg2 commented Apr 27, 2018

Cool! Now I am getting only one failure:

/node_modules/codelyzer/src/noTemplateCallExpressionRule.ts(21,3): error TS4053: Return type of public method from exported class has or is using name 'RuleFailure' from external module "/node_modules/tslint/v5_7_0/src/language/rule/rule" but cannot be named.
        see http://go/typescript/patterns#exported-symbol-cannot-be-named

21   apply(sourceFile: ts.SourceFile) {
     ~~~~~

@mgechev
Copy link
Owner

mgechev commented Apr 27, 2018

@mertdeg2 I added the return type to noTemplateCallExpressionRule. Let me know if the build still fails.

@mertdeg2
Copy link
Author

Nope, this works. Thanks! :)

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

2 participants