Is there a solution where you could do the following?:
my-template.mustache
Hello {{name}}!
index.ts
import { readFileSync, writeFileSync } from 'fs';
import * as Mustache from 'mustache';
export interface Person {
name: string;
}
const hash: Person = {
name: 'Jon'
};
const template = readFileSync('my-template.mustache', 'utf-8');
// somehow let the IDE know the hash type
const result = Mustache.render(template, hash);
writeFileSync('my-template.html', result, 'utf-8');
Then if you did:
my-template.mustache
Hello {{name}}, {{age}} <!-- red squiggles under age -->
So age is not a property of type Person and the hash type is Person so you get red squiggles under age. Preferably a mechanism that would work in in Visual Studio Code.
Update:
To be clear Hello {{name}}, {{age}} <!-- red squiggles under age --> is what I'm trying to accomplish, not the problem I'm having.