This is related to #886, but in this case, when the type is declare'd, it means that some properties do not end up in externs files, causing them to be renamed by the Closure Compiler.
Typescript declarations:
declare interface Base {
a: string
}
declare interface Complex {
field: Base&{b: number};
}
Typescript code:
const complex: Complex = {
field: {b: 3, a: 'hello'}
}
Generated externs:
/**
* @externs
* @suppress {duplicate,checkTypes}
*/
// NOTE: generated by tsickle, do not edit.
/**
* @record
* @struct
*/
function Base() {}
/** @type {string} */
Base.prototype.a;
/**
* @record
* @struct
*/
function Complex() {}
/** @type {?} */
Complex.prototype.field;
Closure output:
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/** @type {!Complex} */
const complex = {
field: { b: 3, a: 'hello' }
};
Compiled code (with rename-properties & generate-pseudo-names):
'use strict';
/**
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode}
*/
const complex = {field:{$b$:3, a:"hello"}};
As you can see, the field param for the type Complex is defined as {?} which causes the field b to never appear in the extern. This causes Closure compiler to rename it in the resulting code.