refactor(compiler-cli): use a transformer for dts files (#28342)
The current DtsFileTransformer works by intercepting file writes and editing the source string directly. This PR refactors it as a afterDeclaration transform in order to fit better in the TypeScript API. This is part of a greater effort of converting ngtsc to be usable as a TS transform plugin. PR Close #28342
This commit is contained in:
@ -449,8 +449,8 @@ describe('ngtsc behavioral tests', () => {
|
||||
const dtsContents = env.getContents('test.d.ts');
|
||||
|
||||
expect(jsContents).toContain('import { Foo } from \'./foo\';');
|
||||
expect(jsContents).not.toMatch(/as i[0-9] from '.\/foo'/);
|
||||
expect(dtsContents).toContain('as i1 from \'./foo\';');
|
||||
expect(jsContents).not.toMatch(/as i[0-9] from ".\/foo"/);
|
||||
expect(dtsContents).toContain('as i1 from "./foo";');
|
||||
});
|
||||
|
||||
it('should compile NgModules with references to absolute components', () => {
|
||||
@ -477,8 +477,8 @@ describe('ngtsc behavioral tests', () => {
|
||||
const dtsContents = env.getContents('test.d.ts');
|
||||
|
||||
expect(jsContents).toContain('import { Foo } from \'foo\';');
|
||||
expect(jsContents).not.toMatch(/as i[0-9] from 'foo'/);
|
||||
expect(dtsContents).toContain('as i1 from \'foo\';');
|
||||
expect(jsContents).not.toMatch(/as i[0-9] from "foo"/);
|
||||
expect(dtsContents).toContain('as i1 from "foo";');
|
||||
});
|
||||
|
||||
it('should compile Pipes without errors', () => {
|
||||
@ -603,7 +603,7 @@ describe('ngtsc behavioral tests', () => {
|
||||
expect(jsContents).toContain('imports: [[RouterModule.forRoot()]]');
|
||||
|
||||
const dtsContents = env.getContents('test.d.ts');
|
||||
expect(dtsContents).toContain(`import * as i1 from 'router';`);
|
||||
expect(dtsContents).toContain(`import * as i1 from "router";`);
|
||||
expect(dtsContents)
|
||||
.toContain('i0.ɵNgModuleDefWithMeta<TestModule, never, [typeof i1.RouterModule], never>');
|
||||
});
|
||||
@ -639,7 +639,7 @@ describe('ngtsc behavioral tests', () => {
|
||||
expect(jsContents).toContain('imports: [[RouterModule.forRoot()]]');
|
||||
|
||||
const dtsContents = env.getContents('test.d.ts');
|
||||
expect(dtsContents).toContain(`import * as i1 from 'router';`);
|
||||
expect(dtsContents).toContain(`import * as i1 from "router";`);
|
||||
expect(dtsContents)
|
||||
.toContain(
|
||||
'i0.ɵNgModuleDefWithMeta<TestModule, never, [typeof i1.InternalRouterModule], never>');
|
||||
@ -673,7 +673,7 @@ describe('ngtsc behavioral tests', () => {
|
||||
expect(jsContents).toContain('imports: [[RouterModule.forRoot()]]');
|
||||
|
||||
const dtsContents = env.getContents('test.d.ts');
|
||||
expect(dtsContents).toContain(`import * as i1 from 'router';`);
|
||||
expect(dtsContents).toContain(`import * as i1 from "router";`);
|
||||
expect(dtsContents)
|
||||
.toContain(
|
||||
'i0.ɵNgModuleDefWithMeta<TestModule, never, [typeof i1.RouterModule], never>');
|
||||
|
Reference in New Issue
Block a user