microsoft / microsoft/TypeChat

JSON validation failed: File '/schema.ts' is not a module.\n'Object' only refers to a type, but is being used as a value here.\nCannot find name 'exports'

Open
#77 8 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
8.7k
Forks
414
Avg merge
3h 8m
Merged PRs (30d)
3

Description

I'm using this function to get summary

export const  getSummary = async (mails:string) =>{
return new Promise(async (resolve,reject)=> {

       const response= await  translator.translate(mails);
       if (!response.success) {
           console.log(response);
           return reject(response);
    }
    const summarizedMail = response.data;
    console.log(JSON.stringify(summarizedMail,undefined, 2));
    if (summarizedMail.summaryObject.type==="unknown") {
        console.log("I didn't understand the following:");
            console.log(summarizedMail.summaryObject.text);
        
    }
    resolve(response)
})

Here's the schema file

export interface SummarizedMailItems {
    type:'mailSummary',
    summarizationLanguage: 'arabic' | 'english' | 'french' | 'spanish'
    summaryParagraph:string ,
    summaryBulletpoints: [string,string,string]
    
}

export interface UnknownText {
    type:'unknown',
    text: string; // The text that wasn't understood
}

export type SummarizedMail = {
    summaryObject: SummarizedMailItems | UnknownText;
};

I'm getting this error

{
  success: false,
  message: "JSON validation failed: File '/schema.ts' is not a module.\n'Object' only refers to a type, but is being used as a value here.\nCannot find name 'exports'.\n{\n  \"paragraphSummary\": \"..........",
}```

Contributor guide

No contributing guide indexed for this repository

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 reproducing the validation failure using the getSummary function and the schema.ts content shown in the issue. Inspect how the schema is loaded and validated, then determine why the exported interfaces produce module, Object, and exports errors. Done means the schema validates successfully and the summarized response can be processed without these errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
ai
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.