angular: ngc not working with static symbols used with Angular 1 code (ngUpgrade)

I’m submitting a …

[x] bug report

Current behavior I’m getting this error:

$ ./node_modules/.bin/ngc
Failed on type {"filePath":"/.../testApp/app/scripts/core/sectionhelp.component.ts","name":"SectionHelpComponent"} with error Error: Error encountered resolving symbol values statically. Qualified type names not supported (position 18:53 in the original .ts file), resolving symbol SectionHelpComponent in /.../testApp/app/scripts/core/section-help.component.ts
Error: Error encountered resolving symbol values statically. Qualified type names not supported (position 18:53 in the original .ts file), resolving symbol SectionHelpComponent in /.../testApp/app/scripts/core/section-help.component.ts
at simplifyInContext (/.../testApp/node_modules/@angular/compiler-cli/src/static_reflector.js:409:23)
at StaticReflector.simplify (/.../testApp/node_modules/@angular/compiler-cli/src/static_reflector.js:412:22)
at StaticReflector.parameters (/.../testApp/node_modules/@angular/compiler-cli/src/static_reflector.js:85:47)
at CompileMetadataResolver.getDependenciesMetadata (/.../testApp/node_modules/@angular/compiler/src/metadata_resolver.js:224:86)
at CompileMetadataResolver.getTypeMetadata (/.../testApp/node_modules/@angular/compiler/src/metadata_resolver.js:173:26)
at CompileMetadataResolver.getDirectiveMetadata (/.../testApp/node_modules/@angular/compiler/src/metadata_resolver.js:136:28)
at CompileMetadataResolver.maybeGetDirectiveMetadata (/.../testApp/node_modules/@angular/compiler/src/metadata_resolver.js:158:25)
at CodeGenerator.readComponents (/.../testApp/node_modules/@angular/compiler-cli/src/codegen.js:62:39)
at generateOneFile (/.../testApp/node_modules/@angular/compiler-cli/src/codegen.js:100:38)
at Array.map (native)
Compilation failed

On this code:

@Component({
    selector: 'section-help',
    templateUrl: 'scripts/core/section-help.component.html',
    directives: [CORE_DIRECTIVES],
    pipes: [TranslateNG1Pipe],
})
export class SectionHelpComponent implements OnInit {
    private language:string;
    private locationHash:string;
    private loading:boolean;
    private helpList:any[];
    private glossaryList:any[];

    constructor(@Inject('$timeout') private $timeout:ng.ITimeoutService,
                @Inject('$location') private $location:ng.ILocationService,
                private HelpService:HelpService) {
    }

If I remove the types from Angular 1 it successfully compiles using ngc:

    constructor(@Inject('$timeout') private $timeout,
                @Inject('$location') private $location,
                private HelpService:HelpService) {
    }

This code works perfectly compiling using tsc in dynamic mode.

Expected/desired behavior Be able to compile using Angular 1 types and custom interfaces.

Please tell us about your environment:

  • Angular version: 2.0.0-rc.3
  • Language: TypeScript 1.9

@alexeagle

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 18 (9 by maintainers)

Commits related to this issue

Most upvoted comments

I’m getting this error 😦

$ ./node_modules/.bin/ngc
TypeError: compiler.ViewResolver is not a constructor
    at Function.CodeGenerator.create (/Users/foo/node_modules/@angular/compiler-cli/src/codegen.js:146:164)
    at codegen (/Users/foo/node_modules/@angular/compiler-cli/src/main.js:7:36)
    at Object.main (/Users/foo/node_modules/@angular/tsc-wrapped/src/main.js:25:16)
    at Object.<anonymous> (/Users/foo/node_modules/@angular/compiler-cli/src/main.js:12:9)
    at Module._compile (module.js:541:32)
    at Object.Module._extensions..js (module.js:550:10)
    at Module.load (module.js:458:32)
    at tryModuleLoad (module.js:417:12)
    at Function.Module._load (module.js:409:3)
    at Function.Module.runMain (module.js:575:10)
Compilation failed

@marcalj No problem. I will commit this as is. It seems to be fixing the underlying problem.

@sod Thanks for verifying this. The error with the ROUTER_PROVIDERS is known and we should fix that soon. The current way ROUTER_PROVIDERS is initialized will not work with the offline compiler but the fix is relatively simple.

@marcalj Not easily. Could you use nvm to change to 5.5?