mockdeep / typewiz

Automatically discover and add missing types in your TypeScript code
https://medium.com/@urish/manual-typing-is-no-fun-introducing-typewiz-58e3e8813f4c
1.1k stars 46 forks source link

Angular problem #80

Closed FallenRiteMonk closed 5 years ago

FallenRiteMonk commented 6 years ago

As mentioned in #73 I tried adding typewiz to a small project of mine using ng add typewiz-angular but it resulted in the following error once running ng serve:

ERROR in : TypeError: Cannot read property 'text' of undefined
    at NodeObject.getText (<PATH_TO_PROJECT>/node_modules/typescript/lib/typescript.js:106700:31)
    at hasParensAroundArguments (<PATH_TO_PROJECT>/node_modules/typewiz-core/dist/transformer.js:29:18)
    at visitor (<PATH_TO_PROJECT>/node_modules/typewiz-core/dist/transformer.js:99:26)
    at visitNodes (<PATH_TO_PROJECT>/node_modules/typescript/lib/typescript.js:56887:48)
    at Object.visitEachChild (<PATH_TO_PROJECT>/node_modules/typescript/lib/typescript.js:57052:156)
    at visitor (<PATH_TO_PROJECT>/node_modules/typewiz-core/dist/transformer.js:78:25)
    at visitNode (<PATH_TO_PROJECT>/node_modules/typescript/lib/typescript.js:56836:23)
    at Object.visitEachChild (<PATH_TO_PROJECT>/node_modules/typescript/lib/typescript.js:57106:49)
    at visitor (<PATH_TO_PROJECT>/node_modules/typewiz-core/dist/transformer.js:78:25)
    at visitNodes (<PATH_TO_PROJECT>/node_modules/typescript/lib/typescript.js:56887:48)
    at Object.visitEachChild (<PATH_TO_PROJECT>/node_modules/typescript/lib/typescript.js:57102:45)
    at visitor (<PATH_TO_PROJECT>/node_modules/typewiz-core/dist/transformer.js:78:25)
    at visitNode (<PATH_TO_PROJECT>/node_modules/typescript/lib/typescript.js:56836:23)
    at visitFunctionBody (<PATH_TO_PROJECT>/node_modules/typescript/lib/typescript.js:56942:23)
    at Object.visitEachChild (<PATH_TO_PROJECT>/node_modules/typescript/lib/typescript.js:56985:510)
    at visitor (<PATH_TO_PROJECT>/node_modules/typewiz-core/dist/transformer.js:78:25)

ERROR in ./src/app/components/features/features.component.ts
Module build failed (from <PATH_TO_PROJECT>/node_modules/@ngtools/webpack/src/index.js):
Error: <PATH_TO_PROJECT>/apps/fortysix/src/app/components/features/features.component.ts is missing from the TypeScript compilation. Please make sure it is in your tsconfig via the 'files' or 'include' property.
    at AngularCompilerPlugin.getCompiledFile (<PATH_TO_PROJECT>/node_modules/@ngtools/webpack/src/angular_compiler_plugin.js:754:23)
    at plugin.done.then (<PATH_TO_PROJECT>/node_modules/@ngtools/webpack/src/loader.js:41:31)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)
ERROR in ./src/app/components/product-detail/product-detail.component.ts
Module build failed (from <PATH_TO_PROJECT>/node_modules/@ngtools/webpack/src/index.js):
Error: <PATH_TO_PROJECT>/apps/fortysix/src/app/components/product-detail/product-detail.component.ts is missing from the TypeScript compilation. Please make sure it is in your tsconfig via the 'files' or 'include' property.
    at AngularCompilerPlugin.getCompiledFile (<PATH_TO_PROJECT>/node_modules/@ngtools/webpack/src/angular_compiler_plugin.js:754:23)
    at plugin.done.then (<PATH_TO_PROJECT>/node_modules/@ngtools/webpack/src/loader.js:41:31)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)
ERROR in ./src/app/components/side-nav-container/side-nav-container.component.ts
Module build failed (from <PATH_TO_PROJECT>/node_modules/@ngtools/webpack/src/index.js):
Error: <PATH_TO_PROJECT>/apps/fortysix/src/app/components/side-nav-container/side-nav-container.component.ts is missing from the TypeScript compilation. Please make sure it is in your tsconfig via the 'files' or 'include' property.
    at AngularCompilerPlugin.getCompiledFile (<PATH_TO_PROJECT>/node_modules/@ngtools/webpack/src/angular_compiler_plugin.js:754:23)
    at plugin.done.then (<PATH_TO_PROJECT>/node_modules/@ngtools/webpack/src/loader.js:41:31)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)
ERROR in ./src/polyfills.ts
Module build failed (from <PATH_TO_PROJECT>/node_modules/@ngtools/webpack/src/index.js):
Error: <PATH_TO_PROJECT>/apps/fortysix/src/polyfills.ts is missing from the TypeScript compilation. Please make sure it is in your tsconfig via the 'files' or 'include' property.
    at AngularCompilerPlugin.getCompiledFile (<PATH_TO_PROJECT>/node_modules/@ngtools/webpack/src/angular_compiler_plugin.js:754:23)
    at plugin.done.then (<PATH_TO_PROJECT>/node_modules/@ngtools/webpack/src/loader.js:41:31)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)

Commenting out code in features.component.ts as @urish mentioned in #73 didn't change anything. My feature component is extremely simple:

import { Component, Input } from '@angular/core';

@Component({
  selector: 'fortysix-features',
  templateUrl: './features.component.html',
  styleUrls: ['./features.component.scss']
})
export class FeaturesComponent {
  // @Input()
  // features: string[];
}

Project info:

ng --version

     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/

Angular CLI: 6.2.4
Node: 8.11.4
OS: linux x64
Angular: 6.1.9
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.8.4
@angular-devkit/build-angular     0.8.4
@angular-devkit/build-optimizer   0.8.4
@angular-devkit/build-webpack     0.8.4
@angular-devkit/core              0.8.4
@angular-devkit/schematics        0.8.4
@angular/cdk                      6.4.7
@angular/cli                      6.2.4
@angular/flex-layout              6.0.0-beta.18
@angular/material                 6.4.7
@ngtools/webpack                  6.2.4
@schematics/angular               0.8.4
@schematics/update                0.8.4
rxjs                              6.3.3
typescript                        2.9.2
webpack                           4.20.2

other possible important dependencies:

"dependencies": {
   "@nrwl/nx": "6.4.0",
   "typewiz-angular": "^0.1.1"
},
"devDependencies": {
   "typewiz": "1.2.0",
   "typewiz-webpack": "1.2.0"
}
alecf commented 5 years ago

this is a dupe of #75 as I think the decorator is effectively the same problem as nested arrow functions

urish commented 5 years ago

@FallenRiteMonk thank you for your feedback! As @alecf mentioned, this seems to be related to #75 which has just been fixed! Can you please try with the latest release (typewiz-angular v1.2.1) and report back?

FallenRiteMonk commented 5 years ago

@urish tested it and works fine thanks.

urish commented 5 years ago

@FallenRiteMonk awesome, thanks for your feedback!

Did it find any new types for your project? Was it useful?

FallenRiteMonk commented 5 years ago

Yes found some, but not to many as I just tested it on a small project. Starting next week, I'll use it on a bigger project. I hope to get full power out if it there.

urish commented 5 years ago

Lovely, looking forward to hear how it goes :)