Skip to content

Commit 4ad2f11

Browse files
petebacondarwinIgorMinar
authored andcommitted
test(ivy): implement ngcc specific version of makeProgram (angular#24897)
PR Close angular#24897
1 parent d7aa20d commit 4ad2f11

File tree

1 file changed

+52
-0
lines changed
  • packages/compiler-cli/src/ngcc/test/helpers

1 file changed

+52
-0
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/**
2+
* @license
3+
* Copyright Google Inc. All Rights Reserved.
4+
*
5+
* Use of this source code is governed by an MIT-style license that can be
6+
* found in the LICENSE file at https://angular.io/license
7+
*/
8+
import * as ts from 'typescript';
9+
import {makeProgram as _makeProgram} from '../../../ngtsc/testing/in_memory_typescript';
10+
11+
export {getDeclaration} from '../../../ngtsc/testing/in_memory_typescript';
12+
13+
export function makeProgram(...files: {name: string, contents: string}[]): ts.Program {
14+
return _makeProgram([getFakeCore(), ...files], {allowJs: true, checkJs: false}).program;
15+
}
16+
17+
// TODO: unify this with the //packages/compiler-cli/test/ngtsc/fake_core package
18+
export function getFakeCore() {
19+
return {
20+
name: 'node_modules/@angular/core/index.ts',
21+
contents: `
22+
type FnWithArg<T> = (arg?: any) => T;
23+
24+
function callableClassDecorator(): FnWithArg<(clazz: any) => any> {
25+
return null !;
26+
}
27+
28+
function callableParamDecorator(): FnWithArg<(a: any, b: any, c: any) => void> {
29+
return null !;
30+
}
31+
32+
function makePropDecorator(): any {
33+
}
34+
35+
export const Component = callableClassDecorator();
36+
export const Directive = callableClassDecorator();
37+
export const Injectable = callableClassDecorator();
38+
export const NgModule = callableClassDecorator();
39+
40+
export const Input = makePropDecorator();
41+
42+
export const Inject = callableParamDecorator();
43+
export const Self = callableParamDecorator();
44+
export const SkipSelf = callableParamDecorator();
45+
export const Optional = callableParamDecorator();
46+
47+
export class InjectionToken {
48+
constructor(name: string) {}
49+
}
50+
`
51+
};
52+
}

0 commit comments

Comments
 (0)