parent
9081efa961
commit
ea68ba048a
|
@ -8,10 +8,11 @@
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import * as ts from 'typescript';
|
import * as ts from 'typescript';
|
||||||
|
|
||||||
import {MetadataCollector} from '../metadata/collector';
|
|
||||||
import {ClassMetadata, ConstructorMetadata, FunctionMetadata, METADATA_VERSION, MemberMetadata, MetadataEntry, MetadataError, MetadataImportedSymbolReferenceExpression, MetadataMap, MetadataObject, MetadataSymbolicExpression, MetadataSymbolicReferenceExpression, MetadataValue, MethodMetadata, ModuleExportMetadata, ModuleMetadata, isClassMetadata, isConstructorMetadata, isFunctionMetadata, isInterfaceMetadata, isMetadataError, isMetadataGlobalReferenceExpression, isMetadataImportedSymbolReferenceExpression, isMetadataModuleReferenceExpression, isMetadataSymbolicExpression, isMethodMetadata} from '../metadata/schema';
|
|
||||||
import {MetadataCache} from '../transformers/metadata_cache';
|
import {MetadataCache} from '../transformers/metadata_cache';
|
||||||
|
|
||||||
|
import {MetadataCollector} from './collector';
|
||||||
|
import {ClassMetadata, ConstructorMetadata, FunctionMetadata, METADATA_VERSION, MemberMetadata, MetadataEntry, MetadataError, MetadataImportedSymbolReferenceExpression, MetadataMap, MetadataObject, MetadataSymbolicExpression, MetadataSymbolicReferenceExpression, MetadataValue, MethodMetadata, ModuleExportMetadata, ModuleMetadata, isClassMetadata, isConstructorMetadata, isFunctionMetadata, isInterfaceMetadata, isMetadataError, isMetadataGlobalReferenceExpression, isMetadataImportedSymbolReferenceExpression, isMetadataModuleReferenceExpression, isMetadataSymbolicExpression, isMethodMetadata} from './schema';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// The character set used to produce private names.
|
// The character set used to produce private names.
|
||||||
|
|
|
@ -202,7 +202,7 @@ function pickIdentifier(
|
||||||
context: ts.SourceFile, primary: ts.Identifier, secondaries: ts.Identifier[],
|
context: ts.SourceFile, primary: ts.Identifier, secondaries: ts.Identifier[],
|
||||||
mode: ImportMode): ts.Identifier|null {
|
mode: ImportMode): ts.Identifier|null {
|
||||||
context = ts.getOriginalNode(context) as ts.SourceFile;
|
context = ts.getOriginalNode(context) as ts.SourceFile;
|
||||||
let localIdentifier: ts.Identifier|null = null;
|
|
||||||
if (ts.getOriginalNode(primary).getSourceFile() === context) {
|
if (ts.getOriginalNode(primary).getSourceFile() === context) {
|
||||||
return primary;
|
return primary;
|
||||||
} else if (mode === ImportMode.UseExistingImport) {
|
} else if (mode === ImportMode.UseExistingImport) {
|
||||||
|
|
|
@ -140,8 +140,7 @@ export class NgtscProgram implements api.Program {
|
||||||
sourceFiles: ReadonlyArray<ts.SourceFile>) => {
|
sourceFiles: ReadonlyArray<ts.SourceFile>) => {
|
||||||
if (fileName.endsWith('.d.ts')) {
|
if (fileName.endsWith('.d.ts')) {
|
||||||
data = sourceFiles.reduce(
|
data = sourceFiles.reduce(
|
||||||
(data, sf) => this.compilation !.transformedDtsFor(sf.fileName, data, fileName),
|
(data, sf) => this.compilation !.transformedDtsFor(sf.fileName, data), data);
|
||||||
data);
|
|
||||||
}
|
}
|
||||||
this.host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles);
|
this.host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles);
|
||||||
};
|
};
|
||||||
|
|
|
@ -192,7 +192,7 @@ export class IvyCompilation {
|
||||||
* Process a .d.ts source string and return a transformed version that incorporates the changes
|
* Process a .d.ts source string and return a transformed version that incorporates the changes
|
||||||
* made to the source file.
|
* made to the source file.
|
||||||
*/
|
*/
|
||||||
transformedDtsFor(tsFileName: string, dtsOriginalSource: string, dtsPath: string): string {
|
transformedDtsFor(tsFileName: string, dtsOriginalSource: string): string {
|
||||||
// No need to transform if no changes have been requested to the input file.
|
// No need to transform if no changes have been requested to the input file.
|
||||||
if (!this.dtsMap.has(tsFileName)) {
|
if (!this.dtsMap.has(tsFileName)) {
|
||||||
return dtsOriginalSource;
|
return dtsOriginalSource;
|
||||||
|
|
|
@ -8,8 +8,6 @@
|
||||||
|
|
||||||
import * as ts from 'typescript';
|
import * as ts from 'typescript';
|
||||||
|
|
||||||
import {relativePathBetween} from '../../util/src/path';
|
|
||||||
|
|
||||||
import {CompileResult} from './api';
|
import {CompileResult} from './api';
|
||||||
import {ImportManager, translateType} from './translator';
|
import {ImportManager, translateType} from './translator';
|
||||||
|
|
||||||
|
|
|
@ -310,7 +310,7 @@ export class TypeTranslatorVisitor implements ExpressionVisitor, TypeVisitor {
|
||||||
const exprStr = type.value.visitExpression(this, context);
|
const exprStr = type.value.visitExpression(this, context);
|
||||||
if (type.typeParams !== null) {
|
if (type.typeParams !== null) {
|
||||||
const typeSegments = type.typeParams.map(param => param.visitType(this, context));
|
const typeSegments = type.typeParams.map(param => param.visitType(this, context));
|
||||||
return `${exprStr}<${typeSegments.join(',')}>`;
|
return `${exprStr}<${typeSegments.join(', ')}>`;
|
||||||
} else {
|
} else {
|
||||||
return exprStr;
|
return exprStr;
|
||||||
}
|
}
|
||||||
|
@ -412,7 +412,7 @@ export class TypeTranslatorVisitor implements ExpressionVisitor, TypeVisitor {
|
||||||
|
|
||||||
visitLiteralArrayExpr(ast: LiteralArrayExpr, context: Context): string {
|
visitLiteralArrayExpr(ast: LiteralArrayExpr, context: Context): string {
|
||||||
const values = ast.entries.map(expr => expr.visitExpression(this, context));
|
const values = ast.entries.map(expr => expr.visitExpression(this, context));
|
||||||
return `[${values.join(',')}]`;
|
return `[${values.join(', ')}]`;
|
||||||
}
|
}
|
||||||
|
|
||||||
visitLiteralMapExpr(ast: LiteralMapExpr, context: Context) {
|
visitLiteralMapExpr(ast: LiteralMapExpr, context: Context) {
|
||||||
|
|
|
@ -405,7 +405,7 @@ describe('ngtsc behavioral tests', () => {
|
||||||
|
|
||||||
const dtsContents = getContents('test.d.ts');
|
const dtsContents = getContents('test.d.ts');
|
||||||
expect(dtsContents)
|
expect(dtsContents)
|
||||||
.toContain('i0.ɵNgModuleDef<TestModule, [typeof TestPipe,typeof TestCmp], never, never>');
|
.toContain('i0.ɵNgModuleDef<TestModule, [typeof TestPipe, typeof TestCmp], never, never>');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should unwrap a ModuleWithProviders function if a generic type is provided for it', () => {
|
it('should unwrap a ModuleWithProviders function if a generic type is provided for it', () => {
|
||||||
|
|
Loading…
Reference in New Issue