refactor(ivy): ngcc - fake core and tslib should be typings files (#25445)
Previously these fake files were full TypeScript source files (`.ts`) but this is not necessary as we only need the typings not the implementation. PR Close #25445
This commit is contained in:
parent
48b77459ef
commit
0fa72a8bc8
|
@ -64,49 +64,38 @@ export function makeTestProgram(
|
||||||
// TODO: unify this with the //packages/compiler-cli/test/ngtsc/fake_core package
|
// TODO: unify this with the //packages/compiler-cli/test/ngtsc/fake_core package
|
||||||
export function getFakeCore() {
|
export function getFakeCore() {
|
||||||
return {
|
return {
|
||||||
name: 'node_modules/@angular/core/index.ts',
|
name: 'node_modules/@angular/core/index.d.ts',
|
||||||
contents: `
|
contents: `
|
||||||
type FnWithArg<T> = (arg?: any) => T;
|
type FnWithArg<T> = (arg?: any) => T;
|
||||||
|
|
||||||
function callableClassDecorator(): FnWithArg<(clazz: any) => any> {
|
export declare const Component: FnWithArg<(clazz: any) => any>;
|
||||||
return null !;
|
export declare const Directive: FnWithArg<(clazz: any) => any>;
|
||||||
|
export declare const Injectable: FnWithArg<(clazz: any) => any>;
|
||||||
|
export declare const NgModule: FnWithArg<(clazz: any) => any>;
|
||||||
|
|
||||||
|
export declare const Input: any;
|
||||||
|
|
||||||
|
export declare const Inject: FnWithArg<(a: any, b: any, c: any) => void>;
|
||||||
|
export declare const Self: FnWithArg<(a: any, b: any, c: any) => void>;
|
||||||
|
export declare const SkipSelf: FnWithArg<(a: any, b: any, c: any) => void>;
|
||||||
|
export declare const Optional: FnWithArg<(a: any, b: any, c: any) => void>;
|
||||||
|
|
||||||
|
export declare class InjectionToken {
|
||||||
|
constructor(name: string);
|
||||||
}
|
}
|
||||||
|
|
||||||
function callableParamDecorator(): FnWithArg<(a: any, b: any, c: any) => void> {
|
export declare interface ModuleWithProviders<T = any> {}
|
||||||
return null !;
|
|
||||||
}
|
|
||||||
|
|
||||||
function makePropDecorator(): any {
|
|
||||||
}
|
|
||||||
|
|
||||||
export const Component = callableClassDecorator();
|
|
||||||
export const Directive = callableClassDecorator();
|
|
||||||
export const Injectable = callableClassDecorator();
|
|
||||||
export const NgModule = callableClassDecorator();
|
|
||||||
|
|
||||||
export const Input = makePropDecorator();
|
|
||||||
|
|
||||||
export const Inject = callableParamDecorator();
|
|
||||||
export const Self = callableParamDecorator();
|
|
||||||
export const SkipSelf = callableParamDecorator();
|
|
||||||
export const Optional = callableParamDecorator();
|
|
||||||
|
|
||||||
export class InjectionToken {
|
|
||||||
constructor(name: string) {}
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ModuleWithProviders<T = any> {}
|
|
||||||
`
|
`
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getFakeTslib() {
|
export function getFakeTslib() {
|
||||||
return {
|
return {
|
||||||
name: 'node_modules/tslib/index.ts',
|
name: 'node_modules/tslib/index.d.ts',
|
||||||
contents: `
|
contents: `
|
||||||
export function __decorate(decorators: any[], target: any, key?: string | symbol, desc?: any) {}
|
export declare function __decorate(decorators: any[], target: any, key?: string | symbol, desc?: any);
|
||||||
export function __param(paramIndex: number, decorator: any) {}
|
export declare function __param(paramIndex: number, decorator: any);
|
||||||
export function __metadata(metadataKey: any, metadataValue: any) {}
|
export declare function __metadata(metadataKey: any, metadataValue: any);
|
||||||
`
|
`
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -346,7 +346,7 @@ describe('Fesm2015ReflectionHost [import helper style]', () => {
|
||||||
null;
|
null;
|
||||||
|
|
||||||
const expectedDeclarationNode = getDeclaration(
|
const expectedDeclarationNode = getDeclaration(
|
||||||
program, 'node_modules/@angular/core/index.ts', 'Directive',
|
program, 'node_modules/@angular/core/index.d.ts', 'Directive',
|
||||||
isNamedVariableDeclaration);
|
isNamedVariableDeclaration);
|
||||||
const actualDeclaration = host.getDeclarationOfIdentifier(identifierOfDirective !);
|
const actualDeclaration = host.getDeclarationOfIdentifier(identifierOfDirective !);
|
||||||
expect(actualDeclaration).not.toBe(null);
|
expect(actualDeclaration).not.toBe(null);
|
||||||
|
|
|
@ -1359,7 +1359,8 @@ describe('Esm2015ReflectionHost', () => {
|
||||||
.initializer as ts.Identifier;
|
.initializer as ts.Identifier;
|
||||||
|
|
||||||
const expectedDeclarationNode = getDeclaration(
|
const expectedDeclarationNode = getDeclaration(
|
||||||
program, 'node_modules/@angular/core/index.ts', 'Directive', isNamedVariableDeclaration);
|
program, 'node_modules/@angular/core/index.d.ts', 'Directive',
|
||||||
|
isNamedVariableDeclaration);
|
||||||
const actualDeclaration = host.getDeclarationOfIdentifier(identifierOfDirective);
|
const actualDeclaration = host.getDeclarationOfIdentifier(identifierOfDirective);
|
||||||
expect(actualDeclaration).not.toBe(null);
|
expect(actualDeclaration).not.toBe(null);
|
||||||
expect(actualDeclaration !.node).toBe(expectedDeclarationNode);
|
expect(actualDeclaration !.node).toBe(expectedDeclarationNode);
|
||||||
|
@ -1419,9 +1420,7 @@ describe('Esm2015ReflectionHost', () => {
|
||||||
const values = Array.from(exportDeclarations !.values())
|
const values = Array.from(exportDeclarations !.values())
|
||||||
.map(declaration => [declaration.node.getText(), declaration.viaModule]);
|
.map(declaration => [declaration.node.getText(), declaration.viaModule]);
|
||||||
expect(values).toEqual([
|
expect(values).toEqual([
|
||||||
// TODO clarify what is expected here...
|
[`Directive: FnWithArg<(clazz: any) => any>`, null],
|
||||||
// [`Directive = callableClassDecorator()`, '@angular/core'],
|
|
||||||
[`Directive = callableClassDecorator()`, null],
|
|
||||||
[`a = 'a'`, null],
|
[`a = 'a'`, null],
|
||||||
[`b = a`, null],
|
[`b = a`, null],
|
||||||
[`c = foo`, null],
|
[`c = foo`, null],
|
||||||
|
|
|
@ -365,7 +365,7 @@ describe('Esm5ReflectionHost [import helper style]', () => {
|
||||||
null;
|
null;
|
||||||
|
|
||||||
const expectedDeclarationNode = getDeclaration(
|
const expectedDeclarationNode = getDeclaration(
|
||||||
program, 'node_modules/@angular/core/index.ts', 'Directive',
|
program, 'node_modules/@angular/core/index.d.ts', 'Directive',
|
||||||
isNamedVariableDeclaration);
|
isNamedVariableDeclaration);
|
||||||
const actualDeclaration = host.getDeclarationOfIdentifier(identifierOfDirective !);
|
const actualDeclaration = host.getDeclarationOfIdentifier(identifierOfDirective !);
|
||||||
expect(actualDeclaration).not.toBe(null);
|
expect(actualDeclaration).not.toBe(null);
|
||||||
|
|
|
@ -1514,7 +1514,8 @@ describe('Esm5ReflectionHost', () => {
|
||||||
.initializer as ts.Identifier;
|
.initializer as ts.Identifier;
|
||||||
|
|
||||||
const expectedDeclarationNode = getDeclaration(
|
const expectedDeclarationNode = getDeclaration(
|
||||||
program, 'node_modules/@angular/core/index.ts', 'Directive', isNamedVariableDeclaration);
|
program, 'node_modules/@angular/core/index.d.ts', 'Directive',
|
||||||
|
isNamedVariableDeclaration);
|
||||||
const actualDeclaration = host.getDeclarationOfIdentifier(identifierOfDirective);
|
const actualDeclaration = host.getDeclarationOfIdentifier(identifierOfDirective);
|
||||||
expect(actualDeclaration).not.toBe(null);
|
expect(actualDeclaration).not.toBe(null);
|
||||||
expect(actualDeclaration !.node).toBe(expectedDeclarationNode);
|
expect(actualDeclaration !.node).toBe(expectedDeclarationNode);
|
||||||
|
@ -1590,9 +1591,7 @@ describe('Esm5ReflectionHost', () => {
|
||||||
const values = Array.from(exportDeclarations !.values())
|
const values = Array.from(exportDeclarations !.values())
|
||||||
.map(declaration => [declaration.node.getText(), declaration.viaModule]);
|
.map(declaration => [declaration.node.getText(), declaration.viaModule]);
|
||||||
expect(values).toEqual([
|
expect(values).toEqual([
|
||||||
// TODO: clarify what is expected here...
|
[`Directive: FnWithArg<(clazz: any) => any>`, null],
|
||||||
//[`Directive = callableClassDecorator()`, '@angular/core'],
|
|
||||||
[`Directive = callableClassDecorator()`, null],
|
|
||||||
[`a = 'a'`, null],
|
[`a = 'a'`, null],
|
||||||
[`b = a`, null],
|
[`b = a`, null],
|
||||||
[`c = foo`, null],
|
[`c = foo`, null],
|
||||||
|
|
Loading…
Reference in New Issue