fix(compiler): make tsx file aot compatible

fixes #20555
This commit is contained in:
Trotyl
2017-11-29 15:27:16 +08:00
committed by Alex Rickabaugh
parent d91ff17adc
commit 05ff6c09ca
7 changed files with 80 additions and 8 deletions

View File

@ -905,6 +905,14 @@ describe('compiler (bundled Angular)', () => {
expect(genFiles.find(f => /app\.component\.ngfactory\.ts/.test(f.genFileUrl))).toBeDefined();
expect(genFiles.find(f => /app\.module\.ngfactory\.ts/.test(f.genFileUrl))).toBeDefined();
});
it('should support tsx', () => {
const tsOptions = {jsx: ts.JsxEmit.React};
const {genFiles} =
compile([QUICKSTART_TSX, angularFiles], /* options */ undefined, tsOptions);
expect(genFiles.find(f => /app\.component\.ngfactory\.ts/.test(f.genFileUrl))).toBeDefined();
expect(genFiles.find(f => /app\.module\.ngfactory\.ts/.test(f.genFileUrl))).toBeDefined();
});
});
describe('Bundled library', () => {
@ -978,6 +986,34 @@ const QUICKSTART: MockDirectory = {
}
};
const QUICKSTART_TSX: MockDirectory = {
quickstart: {
app: {
// #20555
'app.component.tsx': `
import {Component} from '@angular/core';
@Component({
template: '<h1>Hello {{name}}</h1>'
})
export class AppComponent {
name = 'Angular';
}
`,
'app.module.ts': `
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
@NgModule({
declarations: [ AppComponent ],
bootstrap: [ AppComponent ]
})
export class AppModule { }
`
}
}
};
const LIBRARY: MockDirectory = {
bolder: {
'public-api.ts': `