@openpkg-ts/sdk 0.54.0 → 0.54.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +13 -22
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1787,6 +1787,12 @@ import ts13 from "typescript";
|
|
|
1787
1787
|
import * as path3 from "node:path";
|
|
1788
1788
|
import ts from "typescript";
|
|
1789
1789
|
var NODE_MODULES_PKG = /node_modules\/(@[^/]+\/[^/]+|[^/]+)/g;
|
|
1790
|
+
function isLibFile(fileName) {
|
|
1791
|
+
return fileName.includes("/typescript/lib/lib.") || fileName.includes("\\typescript\\lib\\lib.");
|
|
1792
|
+
}
|
|
1793
|
+
function isLibSymbol(symbol) {
|
|
1794
|
+
return symbol?.declarations?.some((d) => isLibFile(d.getSourceFile().fileName)) ?? false;
|
|
1795
|
+
}
|
|
1790
1796
|
function packageNameFromPath(fileName) {
|
|
1791
1797
|
return [...fileName.matchAll(NODE_MODULES_PKG)].at(-1)?.[1];
|
|
1792
1798
|
}
|
|
@@ -2827,14 +2833,7 @@ function isPrimitiveName(name) {
|
|
|
2827
2833
|
return PRIMITIVES.has(name);
|
|
2828
2834
|
}
|
|
2829
2835
|
function isBuiltinSymbol(symbol) {
|
|
2830
|
-
|
|
2831
|
-
return false;
|
|
2832
|
-
const declarations = symbol.getDeclarations();
|
|
2833
|
-
if (!declarations || declarations.length === 0)
|
|
2834
|
-
return false;
|
|
2835
|
-
const sourceFile = declarations[0].getSourceFile();
|
|
2836
|
-
const fileName = sourceFile.fileName;
|
|
2837
|
-
return fileName.includes("/typescript/lib/lib.") || fileName.includes("\\typescript\\lib\\lib.");
|
|
2836
|
+
return isLibSymbol(symbol);
|
|
2838
2837
|
}
|
|
2839
2838
|
function getTypeOrigin(type, _checker) {
|
|
2840
2839
|
const symbol = type.getSymbol() ?? type.aliasSymbol;
|
|
@@ -2843,11 +2842,9 @@ function getTypeOrigin(type, _checker) {
|
|
|
2843
2842
|
const declarations = symbol.getDeclarations();
|
|
2844
2843
|
if (!declarations || declarations.length === 0)
|
|
2845
2844
|
return;
|
|
2846
|
-
|
|
2847
|
-
const pkg = packageNameFromPath(fileName);
|
|
2848
|
-
if (pkg === "typescript")
|
|
2845
|
+
if (isLibSymbol(symbol))
|
|
2849
2846
|
return;
|
|
2850
|
-
return
|
|
2847
|
+
return packageNameFromPath(declarations[0].getSourceFile().fileName);
|
|
2851
2848
|
}
|
|
2852
2849
|
function isBuiltinGeneric(name) {
|
|
2853
2850
|
return BUILTIN_GENERICS.has(name);
|
|
@@ -3977,7 +3974,7 @@ class TypeRegistry {
|
|
|
3977
3974
|
const props = {};
|
|
3978
3975
|
const required = [];
|
|
3979
3976
|
const limit = ctx.maxProperties;
|
|
3980
|
-
const isArrayLike = checker.isArrayType(type) || checker.isTupleType(type) || type.symbol?.getName() === "Array" && type.symbol?.getDeclarations()?.[0]?.getSourceFile()?.fileName
|
|
3977
|
+
const isArrayLike = checker.isArrayType(type) || checker.isTupleType(type) || type.symbol?.getName() === "Array" && isLibFile(type.symbol?.getDeclarations()?.[0]?.getSourceFile()?.fileName ?? "");
|
|
3981
3978
|
const isStringLike = type.flags & ts6.TypeFlags.StringLike;
|
|
3982
3979
|
const isNumberLike = type.flags & ts6.TypeFlags.NumberLike;
|
|
3983
3980
|
const included = properties.filter((prop) => {
|
|
@@ -6961,9 +6958,6 @@ function hasInternalTag(typeName, program, sourceFile) {
|
|
|
6961
6958
|
|
|
6962
6959
|
// src/builder/type-expansion.ts
|
|
6963
6960
|
import ts18 from "typescript";
|
|
6964
|
-
function isLibFile(fileName) {
|
|
6965
|
-
return fileName.includes("/typescript/lib/lib.") || fileName.includes("\\typescript\\lib\\lib.");
|
|
6966
|
-
}
|
|
6967
6961
|
function createExternalExpansionPredicate(opts) {
|
|
6968
6962
|
const matchesEntry = (entry, pkg) => {
|
|
6969
6963
|
if (!entry.includes("*"))
|
|
@@ -6972,8 +6966,6 @@ function createExternalExpansionPredicate(opts) {
|
|
|
6972
6966
|
return rx.test(pkg);
|
|
6973
6967
|
};
|
|
6974
6968
|
const packageAllowed = (pkg) => {
|
|
6975
|
-
if (pkg === "typescript")
|
|
6976
|
-
return false;
|
|
6977
6969
|
if (opts.followExternal === true)
|
|
6978
6970
|
return true;
|
|
6979
6971
|
if (Array.isArray(opts.followExternal) && opts.followExternal.some((e) => matchesEntry(e, pkg))) {
|
|
@@ -6985,10 +6977,9 @@ function createExternalExpansionPredicate(opts) {
|
|
|
6985
6977
|
const decl = symbol.declarations?.[0];
|
|
6986
6978
|
if (!decl)
|
|
6987
6979
|
return false;
|
|
6988
|
-
|
|
6989
|
-
if (isLibFile(fileName))
|
|
6980
|
+
if (isLibSymbol(symbol))
|
|
6990
6981
|
return false;
|
|
6991
|
-
const pkg = packageNameFromPath(fileName);
|
|
6982
|
+
const pkg = packageNameFromPath(decl.getSourceFile().fileName);
|
|
6992
6983
|
if (pkg)
|
|
6993
6984
|
return packageAllowed(pkg);
|
|
6994
6985
|
return true;
|
|
@@ -7963,7 +7954,7 @@ function findTypeInProgram(name, checker, program, sourceFile, symFlags) {
|
|
|
7963
7954
|
const entryDir = path10.dirname(sourceFile.fileName);
|
|
7964
7955
|
for (const sf of program.getSourceFiles()) {
|
|
7965
7956
|
const fn = sf.fileName;
|
|
7966
|
-
if (
|
|
7957
|
+
if (isLibFile(fn))
|
|
7967
7958
|
continue;
|
|
7968
7959
|
if (fn.includes("/@types/node/") || fn.includes("\\@types\\node\\"))
|
|
7969
7960
|
continue;
|