首页
学习
活动
专区
圈层
工具
发布
    • 综合排序
    • 最热优先
    • 最新优先
    时间不限
  • 来自专栏前端劝退师

    如何在大型代码仓库中删掉废弃的文件和 exports?

    . ignore interfaces/type aliases that describe a parameter type in the same file) import { Project, TypeGuards tsconfig.json" }); for (const file of project.getSourceFiles()) { file.forEachChild((child) => { if (TypeGuards.isVariableStatement } else if (isExported(child)) checkNode(child); }); } function isExported(node: Node) { return TypeGuards.isExportableNode TypeGuards.isReferenceFindableNode(node)) return; const file = node.getSourceFile(); if ( node.findReferencesAsNodes length === 0 ) console.log( `[${file.getFilePath()}:${node.getStartLineNumber()}: ${ TypeGuards.hasName

    5.6K60发布于 2021-09-08
  • 来自专栏前端从进阶到入院

    如何在大型代码仓库中删掉 6w 行废弃的文件和 exports?

    . ignore interfaces/type aliases that describe a parameter type in the same file) import { Project, TypeGuards tsconfig.json" }); for (const file of project.getSourceFiles()) { file.forEachChild((child) => { if (TypeGuards.isVariableStatement } else if (isExported(child)) checkNode(child); }); } function isExported(node: Node) { return TypeGuards.isExportableNode TypeGuards.isReferenceFindableNode(node)) return; const file = node.getSourceFile(); if ( node.findReferencesAsNodes length === 0 ) console.log( `[${file.getFilePath()}:${node.getStartLineNumber()}: ${ TypeGuards.hasName

    5.5K20编辑于 2022-03-10
  • 来自专栏前端精进之路:从基础到工程化实战

    TypeScript 的核心价值:类型安全、开发体验与团队协作(源于2026年最新、最佳实践总结)

    User&{role:"admin"};条件类型&映射类型:元编程能力展开代码语言:TypeScriptAI代码解释typeNullable<T>={[KinkeyofT]:T[K]|null};类型守卫(TypeGuards

    14920编辑于 2026-04-19
  • 来自专栏前端精进之路:从基础到工程化实战

    TypeScript如何应对AI模型的不确定性?

    类型守卫(TypeGuards):在解析后,使用类型守卫函数来验证提取出的对象是否真的符合ModelResponse接口。只有通过验证,才能将其视为安全的ModelResponse类型进行后续处理。

    10920编辑于 2026-04-18
  • 来自专栏前端精进之路:从基础到工程化实战

    时代的选择——为什么是 TypeScript?

    当AI返回结果时,我们可以通过类型守卫(TypeGuards)对其进行严格的校验。任何不符合预期的数据都会被立即拦截和处理,从而防止“垃圾进,垃圾出”的情况污染我们的核心业务逻辑。

    17320编辑于 2026-04-18
领券