-
-
Notifications
You must be signed in to change notification settings - Fork 1
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
feat(vue-script-setup-converter): Remove defineComponent from import declaration #53
feat(vue-script-setup-converter): Remove defineComponent from import declaration #53
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
@@ -1,3 +1,4 @@ | |||
// TODO: Move to helpers/node.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.
I will handle this in another Pull Request 🙏
.map((x) => { | ||
if (x.isKind(SyntaxKind.ImportDeclaration)) { | ||
if (hasNamedImportIdentifier(x, "defineComponent")) { | ||
removeNamedImportIdentifier(x, "defineComponent"); |
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.
It may be better to extract only the ImportDeclaration
and insert it later.
(I don't want to rewrite the original sorce.)
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.
(I don't want to rewrite the original sorce.)
Pros.
I thought so too, but chose to rewrite the original once, because no real harm would come from rewriting the original at this time, and because duplicating the importDeclaration would have been somewhat tedious.
However, on second thought, I decided that it could be a breeding ground for bugs in the future, so I will fix it.
😺
import type { ImportDeclaration, SourceFile } from "ts-morph"; | ||
import { hasNamedImportIdentifier } from "../helpers/module"; | ||
|
||
export const convertDefineComponentImport = (sourceFile: SourceFile) => { |
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.
I don't think it is a convert to defineComponent
.
export const convertDefineComponentImport = (sourceFile: SourceFile) => { | |
export const convertImportDeclaration = (sourceFile: SourceFile) => { |
@@ -41,6 +43,7 @@ export const convertSrc = (input: string) => { | |||
throw new Error("defineComponent is not found."); | |||
} | |||
|
|||
const defineComponentImport = convertDefineComponentImport(sourceFile) ?? ""; |
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.
Looking here, convertDefineComponentImport
looks good. I prefer converterImportDeclaration
to defineComponentImport
.
…ComponentImportConverter.ts -> packages/vue-script-setup-converter/src/lib/converter/importDeclarationConverter.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.
👍
Remove defineComponent from import declaration because the converted code does not need to import defineComponent.