iabtcf-es icon indicating copy to clipboard operation
iabtcf-es copied to clipboard

__tcfapi type definitions

Open LukasBombach opened this issue 2 years ago • 2 comments

I am looking for official TypeScript type definitions for the window.__tcfapi.

The official repos provide types that allow any string to be passed as command, but I believe this is not sufficient enough.

To my understanding there is a base API with specific commands that I would like to use in a type safe way, eg. something like

declare function TcfApi(
  command: 'addEventListener',
  version: 2,
  callback: (tcData: TCData, success: boolean) => void,
): void;

declare function TcfApi(
  command: 'removeEventListener',
  version: 2,
  callback: (success: boolean) => void,
  listenerId?: number,
): void;

declare global {
  interface Window {
    __tcfapi: typeof TcfApi;
  }
}

Also, they are difficult to access, as discussed in https://github.com/InteractiveAdvertisingBureau/iabtcf-es/issues/172

There are many custom implementations out, like from The Guardian or Spring Media, but I think it would be great to have an official resource for this, that can be relied upon as being accurate

LukasBombach avatar Feb 09 '22 11:02 LukasBombach

Any comment from the maintainers if this is something that could be part of a roadmap? I have been working on three of the major German news websites and all of them need this.

cc @shortaflip

LukasBombach avatar Feb 21 '22 13:02 LukasBombach

Hi @LukasBombach,

If you would like to create a PR for an implementation of your proposal, I can have it reviewed.

shortaflip avatar Apr 05 '22 17:04 shortaflip

@LukasBombach Do you create a PR or can we close this issue?

anderagakura avatar Sep 20 '22 11:09 anderagakura

Hey sorry, my dayjob and two kids are too much, can't really get to this

LukasBombach avatar Sep 21 '22 10:09 LukasBombach