Skip to content

Commit

Permalink
feat: support for angular 5.2 (#493)
Browse files Browse the repository at this point in the history
* fix(i18n): do not warn with interpolation in i18n element

Fix #442

* chore: support for angular 5.2
  • Loading branch information
mgechev committed Jan 18, 2018
1 parent 958d491 commit 6a6b3de
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 24 deletions.
30 changes: 15 additions & 15 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions package.json
Expand Up @@ -47,11 +47,11 @@
},
"homepage": "https://github.com/mgechev/codelyzer#readme",
"devDependencies": {
"@angular/compiler": "^5.0.0",
"@angular/core": "^5.0.0",
"@angular/platform-browser-dynamic": "^5.0.0",
"@angular/common": "^5.0.0",
"@angular/platform-browser": "^5.0.0",
"@angular/compiler": "^5.2.0",
"@angular/core": "^5.2.0",
"@angular/platform-browser-dynamic": "^5.2.0",
"@angular/common": "^5.2.0",
"@angular/platform-browser": "^5.2.0",
"@types/chai": "^3.4.33",
"@types/less": "0.0.31",
"@types/mocha": "^2.2.32",
Expand Down
13 changes: 12 additions & 1 deletion src/angular/templates/jitReflector.ts
Expand Up @@ -54,9 +54,15 @@ const builtinExternalReferences = createBuiltinExternalReferencesMap();
export class JitReflector implements CompileReflector {
private reflectionCapabilities: ReflectionCapabilities;
private builtinExternalReferences = new Map<ExternalReference, any>();

constructor() {
this.reflectionCapabilities = new ReflectionCapabilities();
}

guards() {
return {};
}

componentModuleUrl(type: any, cmpMetadata: Component): string {
const moduleId = cmpMetadata.moduleId;

Expand All @@ -66,24 +72,29 @@ export class JitReflector implements CompileReflector {
} else if (moduleId !== null && moduleId !== void 0) {
throw syntaxError(
`moduleId should be a string in "${stringify(type)}". See https://goo.gl/wIDDiL for more information.\n` +
'If you\'re using Webpack you should inline the template and the styles, see https://goo.gl/X2J8zc.'
`If you're using Webpack you should inline the template and the styles, see https://goo.gl/X2J8zc.`
);
}

return `./${stringify(type)}`;
}

parameters(typeOrFunc: /*Type*/ any): any[][] {
return this.reflectionCapabilities.parameters(typeOrFunc);
}

annotations(typeOrFunc: /*Type*/ any): any[] {
return this.reflectionCapabilities.annotations(typeOrFunc);
}

propMetadata(typeOrFunc: /*Type*/ any): { [key: string]: any[] } {
return this.reflectionCapabilities.propMetadata(typeOrFunc);
}

hasLifecycleHook(type: any, lcProperty: string): boolean {
return this.reflectionCapabilities.hasLifecycleHook(type, lcProperty);
}

resolveExternalReference(ref: ExternalReference): any {
return builtinExternalReferences.get(ref) || ref.runtime;
}
Expand Down
37 changes: 34 additions & 3 deletions src/angular/templates/templateParser.ts
Expand Up @@ -167,7 +167,7 @@ export const parseTemplate = (template: string, directives: DirectiveDeclaration
componentViewType: null,
rendererType: null,
componentFactory: null
}),
} as any),
template,
defaultDirectives,
[],
Expand Down Expand Up @@ -196,15 +196,15 @@ export const parseTemplate = (template: string, directives: DirectiveDeclaration
componentViewType: null,
rendererType: null,
componentFactory: null
}),
} as any),
template,
defaultDirectives,
[],
[NO_ERRORS_SCHEMA],
''
).templateAst;
})
.else(() => {
.elseIf.lt('5.2.0', () => {
result = tmplParser.tryParse(
compiler.CompileDirectiveMetadata.create({
type,
Expand All @@ -225,6 +225,37 @@ export const parseTemplate = (template: string, directives: DirectiveDeclaration
componentViewType: null,
rendererType: null,
componentFactory: null
} as any),
template,
defaultDirectives,
[],
[NO_ERRORS_SCHEMA],
'',
true
).templateAst;
})
.else(() => {
result = tmplParser.tryParse(
compiler.CompileDirectiveMetadata.create({
type,
template: templateMetadata,
isHost: true,
isComponent: true,
selector: '',
exportAs: '',
changeDetection: ChangeDetectionStrategy.Default,
inputs: [],
outputs: [],
host: {},
providers: [],
viewProviders: [],
queries: [],
viewQueries: [],
entryComponents: [],
componentViewType: null,
rendererType: null,
componentFactory: null,
guards: {}
}),
template,
defaultDirectives,
Expand Down

0 comments on commit 6a6b3de

Please sign in to comment.