@waiting/shared-types-dev
Advanced tools
Comparing version 14.3.2 to 14.3.3
@@ -149,23 +149,22 @@ import assert from 'node:assert'; | ||
// import(".../packages/kmore-types/dist/index").DbDict<import(".../packages/kmore/test/test.model").Db>' | ||
const txt = type.getText(); | ||
// const txtRef = type.getText() | ||
// void txtRef | ||
let typeReferenceText = ''; // "DbDict<D>" | ||
if (txt !== 'any') { | ||
try { | ||
try { | ||
// @ts-expect-error | ||
if (typeof input.getTypeNodeOrThrow === 'function') { | ||
// input.getText() => 'dbDict = genDbDict<Db>()' | ||
// @ts-expect-error | ||
if (typeof input.getTypeNodeOrThrow === 'function') { | ||
// input.getText() => 'dbDict = genDbDict<Db>()' | ||
// @ts-expect-error | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-call | ||
const typeReference = input.getTypeNodeOrThrow(); | ||
typeReferenceText = typeReference.getText(); | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access | ||
// if (typeReference.getKind() !== SyntaxKind.TypeReference) { | ||
// throw new TypeError(`Variable type must be TypeReference, like "const dict: DbDict<Db> = ..."`) | ||
// } | ||
} | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-call | ||
const typeReference = input.getTypeNodeOrThrow(); | ||
typeReferenceText = typeReference.getText(); | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access | ||
// if (typeReference.getKind() !== SyntaxKind.TypeReference) { | ||
// throw new TypeError(`Variable type must be TypeReference, like "const dict: DbDict<Db> = ..."`) | ||
// } | ||
} | ||
catch (ex) { | ||
void 0; | ||
} | ||
} | ||
catch (ex) { | ||
void 0; | ||
} | ||
const ret = { | ||
@@ -172,0 +171,0 @@ name, line, column, type, typeReferenceText, |
import { deepFind } from '../util.js'; | ||
import { findCallExpressionsByName, retrieveVarInfoFromCallExpression, } from './morph-common.js'; | ||
import { findCallExpressionsByName, retrieveFirstTypeArgTextFromCallExpression, retrieveVarInfoFromCallExpression, } from './morph-common.js'; | ||
export class ComputedLiteralType { | ||
@@ -51,6 +51,6 @@ retMap; | ||
} | ||
if (!info.type.getText() && !info.typeReferenceText) { | ||
const typeText = info.typeReferenceText ? info.typeReferenceText : info.type.getText(); | ||
if (!typeText) { | ||
throw new Error('typeof variable is invalid'); | ||
} | ||
const typeText = info.typeReferenceText ? info.typeReferenceText : info.type.getText(); | ||
const posKey = `${info.name}:${info.line}:${info.column}`; | ||
@@ -95,3 +95,8 @@ if (posKeyMap.has(posKey)) { | ||
if (typeReferenceText === 'any') { | ||
return {}; | ||
const gt = retrieveFirstTypeArgTextFromCallExpression(express); | ||
const path = file.getFilePath(); | ||
const msg = `Generic type "${gt}" is resolved "any" in file "${path}" | ||
You can append variable type definition like: "const dict: DbDict<foo> = ...." to fix it | ||
`; | ||
throw new TypeError(msg); | ||
} | ||
@@ -98,0 +103,0 @@ // let typeText = '' |
{ | ||
"name": "@waiting/shared-types-dev", | ||
"author": "waiting", | ||
"version": "14.3.2", | ||
"version": "14.3.3", | ||
"description": "shared typescript types devel", | ||
@@ -77,3 +77,3 @@ "private": false, | ||
}, | ||
"gitHead": "df81ae48d61c2ef46d94c74c931acfb32aba1107" | ||
"gitHead": "cf6685e50237ae5e7236fa2a0ab0e8c61dabb533" | ||
} |
@@ -238,23 +238,22 @@ import assert from 'node:assert' | ||
// import(".../packages/kmore-types/dist/index").DbDict<import(".../packages/kmore/test/test.model").Db>' | ||
const txt = type.getText() | ||
// const txtRef = type.getText() | ||
// void txtRef | ||
let typeReferenceText = '' // "DbDict<D>" | ||
if (txt !== 'any') { | ||
try { | ||
try { | ||
// @ts-expect-error | ||
if (typeof input.getTypeNodeOrThrow === 'function') { | ||
// input.getText() => 'dbDict = genDbDict<Db>()' | ||
// @ts-expect-error | ||
if (typeof input.getTypeNodeOrThrow === 'function') { | ||
// input.getText() => 'dbDict = genDbDict<Db>()' | ||
// @ts-expect-error | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-call | ||
const typeReference = input.getTypeNodeOrThrow() as ts.TypeReferenceNode | ||
typeReferenceText = typeReference.getText() | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access | ||
// if (typeReference.getKind() !== SyntaxKind.TypeReference) { | ||
// throw new TypeError(`Variable type must be TypeReference, like "const dict: DbDict<Db> = ..."`) | ||
// } | ||
} | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-call | ||
const typeReference = input.getTypeNodeOrThrow() as ts.TypeReferenceNode | ||
typeReferenceText = typeReference.getText() | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access | ||
// if (typeReference.getKind() !== SyntaxKind.TypeReference) { | ||
// throw new TypeError(`Variable type must be TypeReference, like "const dict: DbDict<Db> = ..."`) | ||
// } | ||
} | ||
catch (ex) { void 0 } | ||
} | ||
catch (ex) { void 0 } | ||
@@ -261,0 +260,0 @@ const ret = { |
@@ -16,2 +16,3 @@ /* eslint-disable @typescript-eslint/ban-types */ | ||
findCallExpressionsByName, | ||
retrieveFirstTypeArgTextFromCallExpression, | ||
retrieveVarInfoFromCallExpression, | ||
@@ -90,6 +91,6 @@ } from './morph-common.js' | ||
} | ||
if (! info.type.getText() && ! info.typeReferenceText) { | ||
const typeText = info.typeReferenceText ? info.typeReferenceText : info.type.getText() | ||
if (! typeText) { | ||
throw new Error('typeof variable is invalid') | ||
} | ||
const typeText = info.typeReferenceText ? info.typeReferenceText : info.type.getText() | ||
const posKey = `${info.name}:${info.line}:${info.column}` as CallExpressionPosKey | ||
@@ -145,3 +146,8 @@ if (posKeyMap.has(posKey)) { | ||
if (typeReferenceText === 'any') { | ||
return {} | ||
const gt = retrieveFirstTypeArgTextFromCallExpression(express) | ||
const path = file.getFilePath() | ||
const msg = `Generic type "${gt}" is resolved "any" in file "${path}" | ||
You can append variable type definition like: "const dict: DbDict<foo> = ...." to fix it | ||
` | ||
throw new TypeError(msg) | ||
} | ||
@@ -148,0 +154,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
181982
3239