-
Notifications
You must be signed in to change notification settings - Fork 404
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: 修复ts中使用gogocode一系列的类型报错问题 #115
Conversation
TS中使用问题还挺多,晚点再 补充一下PR const ast = AST(readFile(v))
const ImportDeclaration = ast.find({ type: 'ImportDeclaration' })
ImportDeclaration.each(node => {
const value = node.attr('source.value')
if (value.includes(old)) {
// 替换新的名称
node.attr('source.value', value.replace(old, newValue))
// 前面插入注释节点
node.before({
type: 'CommentLine',
value: 'text',
})
}
}) |
@yexi-xf 大佬 Review 一波 |
+1 ,使用 TS 无法使用类型 😳 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hi,这个看起来只是改了一下导出的变量名,是如何解决导出的类型问题的呢?
导出名称与上面命名空间一致即可namespace GoGoCode |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
导出名称与上面命名空间一致即可
namespace GoGoCode
export = GoGoCode
这样TS就能正常工作,引入类型的时候就从 namespace取类型
学习了,感谢指教! |
ASTNode 貌似没有导出来 |
可以这样 import $, { GoGoOption, GoGoAST } from 'gogocode'
type ASTNode = GoGoAST['node'] |
可以使用,感谢感谢 🙏
On Jan 11, 2022, at 11:01 AM, sugar ***@***.******@***.***>> wrote:
type ASTNode = GoGoAST['node']
|
当前的类型定义,对
TS
中使用不是很友好,此次 PR 主要解决下述出现的问题在ts中使用
GoGoCode
时类型检测报错使用方法如下
目前会有下面的类型报错问题
Problem1
ts报错信息
Problem2
当前实现无法在
ts
中使用GoGoCode
中其它类型错误提示信息