本文整理匯總了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
});
}