To repro: go to DefinitelyTyped/types/meteor-astronomy and tsc. The excess property error only happens when the target type is any.
// @Filename: meteor.d.ts
interface User {
_id: string;
username?: string;
emails?: UserEmail[];
createdAt?: Date;
profile?: any;
services?: any;
}
// @Filename: meteor-astronomy.d.ts
// .... snip ...
interface UserInterface extends Meteor.User {
address: object;
firstName: string;
lastName: string;
phone: string;
phoneNumber: string;
fullName: (param: string) => string;
}
const User = Class.create<UserInterface>({
name: 'User',
collection: Meteor.users as unknown as Mongo.Collection<UserInterface>,
fields: {
createdAt: Number,
emails: {
type: [Object],
default: (): Meteor.UserEmail[] => [],
},
profile: { // excess property here
type: UserProfile,
default: () => {},
},
address: {
type: Object,
optional: true
},
firstName: String,
lastName: String,
phone: {
type: String,
resolve(doc: UserInterface) {
return doc.phoneNumber;
},
},
phoneNumber: {
type: String,
},
},
// ...
Expected behavior:
No excess property error.
Actual behavior:
Excess property error. Changing the type of User.profile to unknown (or any other type) makes the error go away.
To repro: go to DefinitelyTyped/types/meteor-astronomy and
tsc. The excess property error only happens when the target type isany.Expected behavior:
No excess property error.
Actual behavior:
Excess property error. Changing the type of
User.profiletounknown(or any other type) makes the error go away.