Угловой 9 (без плюща) как получить _view из ViewContainerRef?

#angular #angular9 #angular-ivy

Вопрос:

У меня есть проект (который работал несколько дней назад) , в котором используется angular 9 без Айви

tsconfig

 {
    "angularCompilerOptions": {
        "enableIvy": false,
    },
"compilerOptions": {
        "downlevelIteration": true,
        "target": "es2015",
        "module": "esnext",
        "moduleResolution": "Node",
        "sourceMap": true,
        "emitDecoratorMetadata": true,
        "experimentalDecorators": true,
        "lib": [
            "es2018",
            "dom"
        ],
        "noImplicitAny": true,
        "suppressImplicitAnyIndexErrors": true,
        "outDir": "dist",
        "types": [
            "node"
        ],
        "typeRoots": [
            "node_modules/@types"
        ]
    },
    
}
 

Моя директива

 export class SomeDirective {


    constructor(viewContainerRef: ViewContainerRef) {
        this.workspace = (viewContainerRef as any)._view.component;
    }
    
}
 

По какой-то причине (вероятно, в пути к классу) я получил и ошибку, когда пытаюсь получить ViewContainerRef._view.

 TypeError: Cannot read property 'component' of undefined
    at new SomeDirectiveDirective (someDirective.directive.ts:18)
    at NodeInjectorFactory.SomeDirectiveDirective_Factory [as factory] (ɵfac.js? [sm]:1)
    at getNodeInjectable (core.js:5993)
    at instantiateAllDirectives (core.js:12997)
    at createDirectivesInstances (core.js:12209)
    at ɵɵelementStart (core.js:21302)
    at WorkspaceComponent_Template (template.html:1)
    at executeTemplate (core.js:12169)
 

Когда я отлаживаю его, я вижу, что ViewContainerRef содержит не _view, а _hostView.

Откуда берутся значения _view и _hostView? Это связано с компилятором Ivy? Если это так, это означает, что мои «angularCompilerOptions» игнорируются, верно?

 ng version 

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

Angular CLI: 9.1.15
Node: 12.3.1
OS: win32 x64

Angular: 9.1.13
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... platform-server, router
Ivy Workspace: No

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.901.15
@angular-devkit/build-angular     0.901.15
@angular-devkit/build-optimizer   0.901.15
@angular-devkit/core              9.1.15
@angular-devkit/schematics        9.1.15
@angular/cdk                      9.2.4
@angular/cli                      9.1.15
@angular/material                 9.2.4
@ngtools/webpack                  9.1.15
@schematics/angular               9.1.15
@schematics/update                0.901.15
rxjs                              6.6.7
typescript                        3.8.3
webpack                           4.46.0
 

PS — Достаточно ли этой информации?
Изменить — Добавлены параметры компилятора