fix(tsc-wrapped): add metadata for type declarations (#18704)

Closes #18675

test(tsc-wrapped): fix collector tests

refactor(tsc-wrapped): change `__symbolic` to `interface` for `TypeAliasDeclaration`

tsc-wrapped: reword test

PR Close #18704
This commit is contained in:
Alan Agius
2017-08-15 16:39:54 +02:00
committed by Miško Hevery
parent 7bfd850493
commit 6e3498ca8e
2 changed files with 28 additions and 5 deletions

View File

@ -34,6 +34,7 @@ describe('Collector', () => {
'exported-classes.ts',
'exported-functions.ts',
'exported-enum.ts',
'exported-type.ts',
'exported-consts.ts',
'local-symbol-ref.ts',
'local-function-ref.ts',
@ -66,6 +67,13 @@ describe('Collector', () => {
expect(metadata).toBeUndefined();
});
it('should return an interface reference for types', () => {
const sourceFile = program.getSourceFile('/exported-type.ts');
const metadata = collector.getMetadata(sourceFile);
expect(metadata).toEqual(
{__symbolic: 'module', version: 3, metadata: {SomeType: {__symbolic: 'interface'}}});
});
it('should return an interface reference for interfaces', () => {
const sourceFile = program.getSourceFile('app/hero.ts');
const metadata = collector.getMetadata(sourceFile);
@ -945,7 +953,7 @@ describe('Collector', () => {
it('should be able to substitute a lambda', () => {
const source = createSource(`
const b = 1;
export const a = () => b;
export const a = () => b;
`);
const metadata = collector.getMetadata(source, /* strict */ false, (value, node) => {
if (node.kind === ts.SyntaxKind.ArrowFunction) {
@ -965,7 +973,7 @@ describe('Collector', () => {
});
const source = createSource(`
const b = 1;
export const a = () => b;
export const a = () => b;
`);
const metadata = collector.getMetadata(source, /* strict */ false, (value, node) => {
if (node.kind === ts.SyntaxKind.ArrowFunction) {
@ -1272,6 +1280,9 @@ const FILES: Directory = {
}
export declare function declaredFn();
`,
'exported-type.ts': `
export type SomeType = 'a' | 'b';
`,
'exported-enum.ts': `
import {constValue} from './exported-consts';