microsoft / microsoft/AdaptiveCards

No types definition found for Tables

Open
#9,059 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Area-Schema Bug
Dominant language
C#
Stars
2k
Forks
595
Avg merge
1d 19h
Merged PRs (30d)
1

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the TypeScript definition of IAdaptiveCard and the existing schema declarations for body elements. Compare the missing Table and msteams definitions with the Adaptive Card schema version 1.5 and the platform extension described in the issue. Done means consumers can use those card shapes without local type overrides, with the relevant type checks passing.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
developer-experience
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.