3
あなたが次のことを行うことができます解決策はあります?:タイプセーフ口ひげテンプレート
私-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');
次に、あなたがやった場合:
my-template.mustache
あなたがage
の下に赤い波線を得る
Hello {{name}}, {{age}} <!-- red squiggles under age -->
のでage
は人タイプのプロパティではなく、ハッシュタイプは、人です。好ましくは、Visual Studio Codeで動作するメカニズム。
更新:
はHello {{name}}, {{age}} <!-- red squiggles under age -->
は私が達成しようとしているものです明確にするためには、ない私がいる問題。
人は例です。私が抱えている問題ではなく、私が成し遂げようとしている(タイプセーフティー)のは、「時代遅れの赤い波」です。 –