Nicholas Albion
Nicholas Albion

Reputation: 3284

"Type expected" in .d.ts file

Can somebody please explain why this is failing, and how to correct it?

https://travis-ci.org/DefinitelyTyped/DefinitelyTyped/builds/102481354

google.analytics/ga.d.ts(59,22): error TS1110: Type expected.
google.analytics/ga.d.ts(64,37): error TS1005: ',' expected.
google.analytics/ga.d.ts(64,38): error TS1128: Declaration or statement expected.
google.analytics/ga.d.ts(64,39): error TS1128: Declaration or statement expected.

It seems that a literal value is acceptable on a function parameter, but not as a restriction on an object field within a function parameter. What's the best way around this?

https://github.com/nalbion/DefinitelyTyped/blob/master/google.analytics/ga.d.ts

declare module UniversalAnalytics {
interface ga {
// ...
// this works:
    (command: 'send', hitType: 'event', eventCategory: string, eventAction: string,
        eventLabel?: string, eventValue?: number, fieldsObject?: {}): void;
    (command: 'send', hitType: 'event', fieldsObject: {
        eventCategory: string,
        eventAction: string,
        eventLabel?: string,
        eventValue?: number,
        nonInteraction?: boolean}): void;
// but this doesn't (line 58 follows)
    (command: 'send', fieldsObject: {
        hitType: 'event',
        eventCategory: string,
        eventAction: string,
        eventLabel?: string,
        eventValue?: number,
        nonInteraction?: boolean}): void;

Upvotes: 2

Views: 5571

Answers (1)

basarat
basarat

Reputation: 276199

hitType: 'event',

This needs support of string unions which although added to TypeScript latest hasn't been released as a stable version yet and thus the Definitely Typed architecture doesn't support it.

Upvotes: 2

Related Questions