@ts-safeql/eslint-plugin
Advanced tools
Comparing version 0.0.20 to 0.0.21
@@ -16,6 +16,6 @@ "use strict"; | ||
const fp_ts_1 = require("../utils/fp-ts"); | ||
const get_type_properties_1 = require("../utils/get-type-properties"); | ||
const memoize_1 = require("../utils/memoize"); | ||
const node_utils_1 = require("../utils/node.utils"); | ||
const ts_pg_utils_1 = require("../utils/ts-pg.utils"); | ||
const ts_utils_1 = require("../utils/ts.utils"); | ||
const check_sql_config_1 = require("./check-sql.config"); | ||
@@ -213,3 +213,3 @@ const check_sql_utils_1 = require("./check-sql.utils"); | ||
}); | ||
if (typeAnnotationState === "INVALID" || typeAnnotationState === "UNKNOWN") { | ||
if (typeAnnotationState === "INVALID") { | ||
return (0, check_sql_utils_1.reportInvalidTypeAnnotations)({ | ||
@@ -273,7 +273,11 @@ context: context, | ||
const typeNode = typeParameter.params[0]; | ||
const current = (0, ts_utils_1.tsTypeToText)({ checker, parser, typeNode }); | ||
if (current === "UNKNOWN") { | ||
return "UNKNOWN"; | ||
} | ||
return getTypesEquality(current, result); | ||
const typeProperties = (0, get_type_properties_1.getTypeProperties)({ | ||
checker, | ||
parser, | ||
typeNode, | ||
}); | ||
return (0, fp_ts_1.pipe)(fp_ts_1.E.Do, fp_ts_1.E.chain(() => fp_ts_1.E.of((0, get_type_properties_1.toInlineLiteralTypeString)({ | ||
properties: new Map(typeProperties), | ||
isArray: typeNode.type === utils_1.TSESTree.AST_NODE_TYPES.TSArrayType, | ||
}))), fp_ts_1.E.foldW((e) => e, (v) => getTypesEquality(v, result))); | ||
} | ||
@@ -280,0 +284,0 @@ // TODO this should be improved. |
@@ -229,2 +229,55 @@ "use strict"; | ||
}, | ||
{ | ||
filename, | ||
options: withConnection(connections.base), | ||
name: "type annotation with a valid type reference", | ||
code: ` | ||
type Agency = { id: number; name: string }; | ||
conn.query<Agency>(sql\`select id, name from agency\`); | ||
`, | ||
}, | ||
{ | ||
filename, | ||
options: withConnection(connections.base), | ||
name: "type annotation with a valid type reference (interface)", | ||
code: ` | ||
interface Agency { id: number; name: string } | ||
conn.query<Agency>(sql\`select id, name from agency\`); | ||
`, | ||
}, | ||
{ | ||
filename, | ||
options: withConnection(connections.base), | ||
name: "type annotation with a valid intersection", | ||
code: ` | ||
conn.query<{ id: number; } & { name: string; }>(sql\`select id, name from agency\`); | ||
`, | ||
}, | ||
{ | ||
filename, | ||
options: withConnection(connections.base), | ||
name: "type annotation with Pick", | ||
code: ` | ||
interface Agency { id: number; name: string } | ||
conn.query<Pick<Agency, "id" | "name">>(sql\`select id, name from agency\`); | ||
`, | ||
}, | ||
{ | ||
filename, | ||
options: withConnection(connections.base), | ||
name: "type annotation with Pick & intersection", | ||
code: ` | ||
interface Agency { id: number; name: string } | ||
conn.query<Pick<Agency, "id"> & { name: string; }>(sql\`select id, name from agency\`); | ||
`, | ||
}, | ||
{ | ||
filename, | ||
options: withConnection(connections.base), | ||
name: "type annotation with Pick overriden by intersection", | ||
code: ` | ||
interface Agency { id: number; name: string | null } | ||
conn.query<Agency & { name: string; }>(sql\`select id, name from agency\`); | ||
`, | ||
}, | ||
], | ||
@@ -353,3 +406,3 @@ invalid: [ | ||
data: { | ||
expected: "{ }", | ||
expected: "{ }", | ||
actual: "No type annotation", | ||
@@ -356,0 +409,0 @@ }, |
{ | ||
"name": "@ts-safeql/eslint-plugin", | ||
"version": "0.0.20", | ||
"version": "0.0.21", | ||
"main": "lib/index.js", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
369632
5374