Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/lemon-pears-attack.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@wc-toolkit/type-parser": patch
---

Excluded `mode_modules` from parser to prevent infinite loops
6 changes: 3 additions & 3 deletions src/cem-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ function getObjectTypes(fileName: string, typeName: string): string {
}

function getFinalType(type: any): string {
if(isTsType(type)) {
if(isNpmType(type)) {
return typeChecker.typeToString(type);
}
if (type.isUnion()) {
Expand Down Expand Up @@ -253,7 +253,7 @@ function getFinalType(type: any): string {
return typeChecker.typeToString(type);
}

function isTsType(type: ts.Type): boolean {
function isNpmType(type: ts.Type): boolean {
const symbol = type.getSymbol();
if (!symbol) return false;

Expand All @@ -262,7 +262,7 @@ function isTsType(type: ts.Type): boolean {

return declarations.some((decl) => {
const sourceFile = decl.getSourceFile();
return sourceFile.fileName.includes('node_modules/typescript');
return sourceFile.fileName.includes('node_modules');
});
}

Expand Down