diff --git a/packages/compiler-cli/src/ngtsc/core/src/compiler.ts b/packages/compiler-cli/src/ngtsc/core/src/compiler.ts index 7b1b45477e..433c70f387 100644 --- a/packages/compiler-cli/src/ngtsc/core/src/compiler.ts +++ b/packages/compiler-cli/src/ngtsc/core/src/compiler.ts @@ -486,8 +486,7 @@ export class NgCompiler { // Execute the typeCheck phase of each decorator in the program. const prepSpan = this.perfRecorder.start('typeCheckPrep'); const ctx = new TypeCheckContext( - typeCheckingConfig, host, compilation.refEmitter!, compilation.reflector, - host.typeCheckFile); + typeCheckingConfig, compilation.refEmitter!, compilation.reflector, host.typeCheckFile); compilation.traitCompiler.typeCheck(ctx); this.perfRecorder.stop(prepSpan); diff --git a/packages/compiler-cli/src/ngtsc/typecheck/src/context.ts b/packages/compiler-cli/src/ngtsc/typecheck/src/context.ts index 4e5fdbd782..58b866f0f9 100644 --- a/packages/compiler-cli/src/ngtsc/typecheck/src/context.ts +++ b/packages/compiler-cli/src/ngtsc/typecheck/src/context.ts @@ -38,11 +38,9 @@ export class TypeCheckContext { private typeCheckFile: TypeCheckFile; constructor( - private config: TypeCheckingConfig, compilerHost: ts.CompilerHost, - private refEmitter: ReferenceEmitter, private reflector: ReflectionHost, - typeCheckFilePath: AbsoluteFsPath) { - this.typeCheckFile = - new TypeCheckFile(typeCheckFilePath, config, refEmitter, reflector, compilerHost); + private config: TypeCheckingConfig, private refEmitter: ReferenceEmitter, + private reflector: ReflectionHost, typeCheckFilePath: AbsoluteFsPath) { + this.typeCheckFile = new TypeCheckFile(typeCheckFilePath, config, refEmitter, reflector); } /** diff --git a/packages/compiler-cli/src/ngtsc/typecheck/src/type_check_file.ts b/packages/compiler-cli/src/ngtsc/typecheck/src/type_check_file.ts index 5019650c9c..1b5f93f247 100644 --- a/packages/compiler-cli/src/ngtsc/typecheck/src/type_check_file.ts +++ b/packages/compiler-cli/src/ngtsc/typecheck/src/type_check_file.ts @@ -33,12 +33,11 @@ export class TypeCheckFile extends Environment { private tcbStatements: ts.Statement[] = []; constructor( - readonly fileName: AbsoluteFsPath, config: TypeCheckingConfig, refEmitter: ReferenceEmitter, - reflector: ReflectionHost, compilerHost: ts.CompilerHost) { + private fileName: string, config: TypeCheckingConfig, refEmitter: ReferenceEmitter, + reflector: ReflectionHost) { super( config, new ImportManager(new NoopImportRewriter(), 'i'), refEmitter, reflector, - ts.createSourceFile( - compilerHost.getCanonicalFileName(fileName), '', ts.ScriptTarget.Latest, true)); + ts.createSourceFile(fileName, '', ts.ScriptTarget.Latest, true)); } addTypeCheckBlock( @@ -50,7 +49,7 @@ export class TypeCheckFile extends Environment { } render(): ts.SourceFile { - let source: string = this.importManager.getAllImports(this.contextFile.fileName) + let source: string = this.importManager.getAllImports(this.fileName) .map(i => `import * as ${i.qualifier} from '${i.specifier}';`) .join('\n') + '\n\n'; @@ -76,7 +75,7 @@ export class TypeCheckFile extends Environment { source += '\nexport const IS_A_MODULE = true;\n'; return ts.createSourceFile( - this.contextFile.fileName, source, ts.ScriptTarget.Latest, true, ts.ScriptKind.TS); + this.fileName, source, ts.ScriptTarget.Latest, true, ts.ScriptKind.TS); } getPreludeStatements(): ts.Statement[] { diff --git a/packages/compiler-cli/src/ngtsc/typecheck/test/test_utils.ts b/packages/compiler-cli/src/ngtsc/typecheck/test/test_utils.ts index 647766d102..1c3e22192f 100644 --- a/packages/compiler-cli/src/ngtsc/typecheck/test/test_utils.ts +++ b/packages/compiler-cli/src/ngtsc/typecheck/test/test_utils.ts @@ -262,7 +262,7 @@ export function typecheck( new LogicalProjectStrategy(reflectionHost, logicalFs), ]); const ctx = new TypeCheckContext( - {...ALL_ENABLED_CONFIG, ...config}, host, emitter, reflectionHost, typeCheckFilePath); + {...ALL_ENABLED_CONFIG, ...config}, emitter, reflectionHost, typeCheckFilePath); const templateUrl = 'synthetic.html'; const templateFile = new ParseSourceFile(template, templateUrl); diff --git a/packages/compiler-cli/src/ngtsc/typecheck/test/type_constructor_spec.ts b/packages/compiler-cli/src/ngtsc/typecheck/test/type_constructor_spec.ts index 51f6e49d01..16c405531e 100644 --- a/packages/compiler-cli/src/ngtsc/typecheck/test/type_constructor_spec.ts +++ b/packages/compiler-cli/src/ngtsc/typecheck/test/type_constructor_spec.ts @@ -45,7 +45,7 @@ runInEachFileSystem(() => { const host = new NgtscCompilerHost(getFileSystem()); const file = new TypeCheckFile( _('/_typecheck_.ts'), ALL_ENABLED_CONFIG, new ReferenceEmitter([]), - /* reflector */ null!, host); + /* reflector */ null!); const sf = file.render(); expect(sf.statements.length).toBe(1); }); @@ -75,8 +75,8 @@ TestClass.ngTypeCtor({value: 'test'}); new AbsoluteModuleStrategy(program, checker, moduleResolver, reflectionHost), new LogicalProjectStrategy(reflectionHost, logicalFs), ]); - const ctx = new TypeCheckContext( - ALL_ENABLED_CONFIG, host, emitter, reflectionHost, _('/_typecheck_.ts')); + const ctx = + new TypeCheckContext(ALL_ENABLED_CONFIG, emitter, reflectionHost, _('/_typecheck_.ts')); const TestClass = getDeclaration(program, _('/main.ts'), 'TestClass', isNamedClassDeclaration); ctx.addInlineTypeCtor( @@ -111,8 +111,8 @@ TestClass.ngTypeCtor({value: 'test'}); new AbsoluteModuleStrategy(program, checker, moduleResolver, reflectionHost), new LogicalProjectStrategy(reflectionHost, logicalFs), ]); - const ctx = new TypeCheckContext( - ALL_ENABLED_CONFIG, host, emitter, reflectionHost, _('/_typecheck_.ts')); + const ctx = + new TypeCheckContext(ALL_ENABLED_CONFIG, emitter, reflectionHost, _('/_typecheck_.ts')); const TestClass = getDeclaration(program, _('/main.ts'), 'TestClass', isNamedClassDeclaration); ctx.addInlineTypeCtor( @@ -153,8 +153,8 @@ TestClass.ngTypeCtor({value: 'test'}); new AbsoluteModuleStrategy(program, checker, moduleResolver, reflectionHost), new LogicalProjectStrategy(reflectionHost, logicalFs), ]); - const ctx = new TypeCheckContext( - ALL_ENABLED_CONFIG, host, emitter, reflectionHost, _('/_typecheck_.ts')); + const ctx = + new TypeCheckContext(ALL_ENABLED_CONFIG, emitter, reflectionHost, _('/_typecheck_.ts')); const TestClass = getDeclaration(program, _('/main.ts'), 'TestClass', isNamedClassDeclaration); ctx.addInlineTypeCtor(