本文整理汇总了TypeScript中ts-simple-ast.Project.addExistingSourceFile方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Project.addExistingSourceFile方法的具体用法?TypeScript Project.addExistingSourceFile怎么用?TypeScript Project.addExistingSourceFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ts-simple-ast.Project
的用法示例。
在下文中一共展示了Project.addExistingSourceFile方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: verifyDeclarationFile
export function verifyDeclarationFile() {
const project = new Project();
const declarationFile = project.addExistingSourceFile("ts-nameof.d.ts");
const declarationFileTests = project.addExistingSourceFile("lib/declarationFileTests.ts");
const diagnostics = [...declarationFile.getPreEmitDiagnostics(), ...declarationFileTests.getPreEmitDiagnostics()];
if (diagnostics.length > 0)
console.error(project.formatDiagnosticsWithColorAndContext(diagnostics));
}
示例2: addGlobalDeclarations
function addGlobalDeclarations() {
const globalFile = project.addExistingSourceFile("../../shared/lib/global.d.ts");
declarationFile.addStatements(writer => {
writer.newLine();
writer.write(globalFile.getText().replace(/\r?\n$/, ""));
});
}
示例3: createDeclarationFile
export function createDeclarationFile(project: Project) {
const globalFile = project.addExistingSourceFile("../../shared/lib/global.d.ts");
const declarationFile = project.createSourceFile("ts-nameof.macro.d.ts", "", { overwrite: true });
const namespaceDec = declarationFile.addNamespace({
name: `"ts-nameof.macro"`,
declarationKind: NamespaceDeclarationKind.Module,
hasDeclareKeyword: true
});
namespaceDec.setBodyText(globalFile.getFullText());
for (const statement of namespaceDec.getStatements()) {
if (TypeGuards.isAmbientableNode(statement))
statement.setHasDeclareKeyword(false);
}
namespaceDec.addExportAssignment({
expression: "nameof",
isExportEquals: false
});
}