Skip to content

Commit

Permalink
fix: support ts generic
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Apr 20, 2022
1 parent f618c68 commit c085469
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export function stripCommentsAndStrings (code: string) {
}

export function makeMatchRegex (imports: Import[]): RegExp {
return new RegExp(`(?:\\b|^)(${imports.map(i => escapeRE(i.as)).join('|')})\\s*(?:[.(\\)\\[\\];+\\-*&\\|\`])`, 'g')
return new RegExp(`(?:\\b|^)(${imports.map(i => escapeRE(i.as)).join('|')})\\s*(?:[.(\\)\\[\\];+\\-*&\\|\`<>])`, 'g')
}

export function toImports (imports: Import[], isCJS = false) {
Expand Down
5 changes: 5 additions & 0 deletions test/__snapshots__/fixtures.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@ exports[`fixtures > template-tag.ts 1`] = `
"
`;
exports[`fixtures > ts-generic.ts 1`] = `
"import { useState } from 'react';useState<number>()
"
`;
exports[`fixtures > vue.js 1`] = `
"import { ref } from 'vue';const a = ref(0)
"
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/ts-generic.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
useState<number>()

0 comments on commit c085469

Please sign in to comment.