Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No types definition found for Tables #9059

Open
aamir-mns opened this issue Nov 19, 2024 · 0 comments
Open

No types definition found for Tables #9059

aamir-mns opened this issue Nov 19, 2024 · 0 comments

Comments

@aamir-mns
Copy link

aamir-mns commented Nov 19, 2024

Target Application

Microsoft Teams

Application Operating System

iOS

Schema Version

1.5

Problem Description

When I check the type for IAdaptiveCard['body'] I see this:

export interface IAdaptiveCard extends ICardElement {
   // ...other properties
    body?: (ITextBlock | IImage | IImageSet | IFactSet | IColumnSet | IContainer)[];
}

I was trying to use Table for which there is no type definition. Same stand for msteams. Please suggest solution if I am missing something.

Expected Outcome

I should not have to define types for Table and msteams.
At the moment I have this to solve my issue:

import type { IAdaptiveCard } from 'adaptivecards';
import type {
  IOpenUrlAction,
  IShowCardAction,
  ISubmitAction,
  Spacing,
  TextColor,
} from 'adaptivecards/lib/schema';

type TableColumn = {
  width?: number;
};

type TableCell = {
  type: 'TableCell';
  style?: TextColor;
  items: IAdaptiveCard['body'];
};

export type TableRow = {
  type: 'TableRow';
  style?: TextColor;
  cells: TableCell[];
};

type Table = {
  type: 'Table';
  spacing?: Spacing;
  gridStyle?: 'default' | 'accent';
  firstRowAsHeader?: boolean;
  showGridLines?: boolean;
  firstRowAsHeaders?: boolean;
  columns?: TableColumn[];
  rows?: TableRow[];
};

type MsTeams = {
  entities: {
    type: 'mention';
    text: string;
    mentioned: {
      id: string;
      name: string;
    };
  }[];
};

type Body = NonNullable<IAdaptiveCard['body']>[number] | Table;
type IAdaptiveCardWithoutBody = StripIndexSignature<
  Omit<IAdaptiveCard, 'body' | 'actions'>
>;

type ShowCardActionWithOutCard = Omit<IShowCardAction, 'card'>;
type ShowCardActionWithCard = ShowCardActionWithOutCard & {
  card: AdaptiveCard;
};

export type AdaptiveCard = Partial<IAdaptiveCardWithoutBody> & {
  body?: Body[];
  actions?: (ISubmitAction | IOpenUrlAction | ShowCardActionWithCard)[];
};

export type MsTeamsContent = AdaptiveCard & { msteams: MsTeams };

Actual Outcome

I get this error without above changes:
Image

Card JSON

Cannot share private data but I think it is irrelevant.

Repro Steps

No response

@aamir-mns aamir-mns changed the title [Authoring] No types defination found for Tables No types definition found for Tables Nov 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant