2

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; 

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

4 Comments

thanks, what about this one? Specialized overload signature is not assignable to any non-specialized signature.
...and Rest parameter 'fields' implicitly has an 'any[]' type
Specialized overload signature is not assignable to any non-specialized signature if you have argument foo:'asdf' you need a corresponding overload foo:string
Rest parameter 'fields' implicitly has an 'any[]' type A missing type annotation would assume any. Have it as :any[] to make it explicit

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.