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

BasicBot JS template has ts-check errors #13253

Open
ridomin opened this issue Feb 20, 2025 · 2 comments
Open

BasicBot JS template has ts-check errors #13253

ridomin opened this issue Feb 20, 2025 · 2 comments
Labels
needs attention This issue needs the attention of a contributor.

Comments

@ridomin
Copy link

ridomin commented Feb 20, 2025

The code produced by TTK in the basic bot template:

Create new app -> Bot -> Basic Bot -> JS

Has type errors.

Add // @ts-check to teamsBot.js

Image

Copy link

👋 Hi @ridomin,

Thank you for reporting this issue! We want to let you know that:

⏱️ Our team will personally review your issue
🎯 You can expect a response within 2 business days

✨ This is an AI-generated initial response
🤖 AI-Generated Preliminary Analysis:

It seems that you're encountering type errors in the Basic Bot template generated by the Teams Toolkit (TTK) when you add // @ts-check to teamsBot.js. This issue is due to JavaScript files not being type-checked for TypeScript types by default, and adding // @ts-check enables type-checking which then uncovers these issues.

Here's how you can resolve these type errors:

Steps to Resolve Type Errors:

  1. Correct Type Annotations:
    Ensure that the type annotations in your JavaScript code are correct. TypeScript type errors usually occur when the types do not match the expected types defined for the methods and properties.

  2. Convert to TypeScript:
    Since you are adding // @ts-check, it might be more beneficial to convert the JavaScript file to TypeScript. This will give you better type checking and auto-completion features.

    • Rename teamsBot.js to teamsBot.ts.
    • Fix any type errors by providing appropriate type annotations.

Example Conversion to TypeScript:

Original teamsBot.js:

// @ts-check
const { TeamsActivityHandler } = require('botbuilder');

class TeamsBot extends TeamsActivityHandler {
    constructor() {
        super();
        // Your code here
    }
}

module.exports.TeamsBot = TeamsBot;

Converted teamsBot.ts:

import { TeamsActivityHandler } from 'botbuilder';

class TeamsBot extends TeamsActivityHandler {
    constructor() {
        super();
        // Your code here
    }
}

export { TeamsBot };

Additional Steps:

  1. Install TypeScript and Required Types:
    If you haven't already, you will need to install TypeScript and the necessary type definitions.

    npm install typescript @types/node --save-dev
  2. Add a tsconfig.json File:
    Create a tsconfig.json file in the root of your project to configure the TypeScript compiler.

    {
      "compilerOptions": {
        "target": "es6",
        "module": "commonjs",
        "outDir": "dist",
        "rootDir": "src",
        "strict": true,
        "esModuleInterop": true
      },
      "include": ["src/**/*.ts"],
      "exclude": ["node_modules"]
    }

Resources:

  • For more details on configuring TypeScript, you can refer to the official TypeScript documentation: TypeScript Configuration.

By following these steps, you should be able to resolve the type errors in your Basic Bot template. If the problem persists, please share the specific type errors you are encountering for further assistance.


Note: This is an automated first response generated by AI. A human team member will review your issue and provide a more detailed response soon. We appreciate your patience!

@microsoft-github-policy-service microsoft-github-policy-service bot added the needs attention This issue needs the attention of a contributor. label Feb 20, 2025
@ridomin ridomin changed the title BasicBot template has ts-check errors BasicBot JS template has ts-check errors Feb 20, 2025
@sayali-MSFT
Copy link

@ridomin ,Thank you for your inquiry about your Teams app development issue!
We are checking the issue. We will get back to you shortly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs attention This issue needs the attention of a contributor.
Projects
None yet
Development

No branches or pull requests

2 participants