ts-gem-plugin 0.0.7 → 0.0.8
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 +28 -7
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -266,7 +266,8 @@ function isCustomElementTag(tag) {
|
|
|
266
266
|
return tag.includes("-");
|
|
267
267
|
}
|
|
268
268
|
function isDepElement(node) {
|
|
269
|
-
|
|
269
|
+
const { fileName } = node.getSourceFile();
|
|
270
|
+
return ["/node_modules/", "/dist/", ".d.ts"].some((s) => fileName.includes(s));
|
|
270
271
|
}
|
|
271
272
|
function bindMemberFunction(o, keys2 = Object.keys(o)) {
|
|
272
273
|
return Object.fromEntries(keys2.map((key) => [key, o[key].bind?.(o)]));
|
|
@@ -1009,7 +1010,8 @@ var HTMLLanguageService = class {
|
|
|
1009
1010
|
const diagnostics = [];
|
|
1010
1011
|
forEachNode(vHtml.roots, (node) => {
|
|
1011
1012
|
if (!node.tag) return;
|
|
1012
|
-
|
|
1013
|
+
const customElementTagDecl = this.#ctx.elements.get(node.tag);
|
|
1014
|
+
if (isCustomElementTag(node.tag) && !customElementTagDecl) {
|
|
1013
1015
|
diagnostics.push({
|
|
1014
1016
|
category: context.typescript.DiagnosticCategory.Warning,
|
|
1015
1017
|
code: 101 /* UnknownTag */,
|
|
@@ -1020,13 +1022,13 @@ var HTMLLanguageService = class {
|
|
|
1020
1022
|
source: NAME
|
|
1021
1023
|
});
|
|
1022
1024
|
}
|
|
1023
|
-
const tagDeclaration =
|
|
1025
|
+
const tagDeclaration = customElementTagDecl || this.#ctx.builtInElements.get(node.tag);
|
|
1024
1026
|
if (!tagDeclaration) return;
|
|
1025
1027
|
for (const [attributeName, { value, start, end }] of node.attributesMap) {
|
|
1026
1028
|
if (attributeName.startsWith("_")) continue;
|
|
1027
1029
|
const hasValueSpan = value?.startsWith("_");
|
|
1028
1030
|
const attrInfo = getAttrName(attributeName);
|
|
1029
|
-
const propType = getPropType(typeChecker, tagDeclaration, attrInfo);
|
|
1031
|
+
const propType = getPropType(typeChecker, tagDeclaration, !customElementTagDecl, attrInfo);
|
|
1030
1032
|
const diagnostic = {
|
|
1031
1033
|
category: context.typescript.DiagnosticCategory.Warning,
|
|
1032
1034
|
file,
|
|
@@ -1185,12 +1187,19 @@ function getSpanType(typescript, typeChecker, file, htmlOffset, attrNameEnd) {
|
|
|
1185
1187
|
const spanExp = getSpanExpression(typescript, file, valueOffset);
|
|
1186
1188
|
return typeChecker.getTypeAtLocation(spanExp);
|
|
1187
1189
|
}
|
|
1188
|
-
|
|
1190
|
+
var buildInElementNoGlobalAttrPropMap = /* @__PURE__ */ new Map([
|
|
1191
|
+
["crossorigin", "crossOrigin"],
|
|
1192
|
+
["rowspan", "rowSpan"],
|
|
1193
|
+
["colspan", "colSpan"],
|
|
1194
|
+
// <input> list: string
|
|
1195
|
+
["list", "ariaLabelledby"]
|
|
1196
|
+
]);
|
|
1197
|
+
function getPropType(typeChecker, tagClassDeclaration, isBuiltInTag, attrInfo) {
|
|
1189
1198
|
const classType = typeChecker.getTypeAtLocation(tagClassDeclaration);
|
|
1190
1199
|
if (attrInfo.attr.startsWith("data-")) {
|
|
1191
1200
|
return typeChecker.getStringType();
|
|
1192
1201
|
}
|
|
1193
|
-
const propName = kebabToCamelCase(attrInfo.attr);
|
|
1202
|
+
const propName = isBuiltInTag ? buildInElementNoGlobalAttrPropMap.get(attrInfo.attr) || kebabToCamelCase(attrInfo.attr) : kebabToCamelCase(attrInfo.attr);
|
|
1194
1203
|
switch (propName) {
|
|
1195
1204
|
case "class":
|
|
1196
1205
|
case "style":
|
|
@@ -1198,12 +1207,24 @@ function getPropType(typeChecker, tagClassDeclaration, attrInfo) {
|
|
|
1198
1207
|
case "exportparts":
|
|
1199
1208
|
case "xmlns":
|
|
1200
1209
|
case "viewBox":
|
|
1210
|
+
case "ariaLabelledby":
|
|
1201
1211
|
return typeChecker.getStringType();
|
|
1202
1212
|
case "tabindex":
|
|
1203
1213
|
return typeChecker.getNumberType();
|
|
1204
|
-
case "
|
|
1214
|
+
case "ariaAtomic":
|
|
1215
|
+
case "ariaBusy":
|
|
1205
1216
|
case "ariaChecked":
|
|
1217
|
+
case "ariaDisabled":
|
|
1218
|
+
case "ariaExpanded":
|
|
1219
|
+
case "ariaGrabbed":
|
|
1206
1220
|
case "ariaHidden":
|
|
1221
|
+
case "ariaModal":
|
|
1222
|
+
case "ariaMultiline":
|
|
1223
|
+
case "ariaMultiselectable":
|
|
1224
|
+
case "ariaReadonly":
|
|
1225
|
+
case "ariaRequired":
|
|
1226
|
+
case "ariaPressed":
|
|
1227
|
+
case "ariaSelected":
|
|
1207
1228
|
return getUnionType(typeChecker, [
|
|
1208
1229
|
typeChecker.getStringType(),
|
|
1209
1230
|
typeChecker.getBooleanType(),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ts-gem-plugin",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.8",
|
|
4
4
|
"description": "Typescript language service plugin for Gem",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"gem",
|
|
@@ -14,17 +14,17 @@
|
|
|
14
14
|
"prepublishOnly": "pnpm run build"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@mantou/gem": "^2.2.
|
|
17
|
+
"@mantou/gem": "^2.2.1",
|
|
18
18
|
"@mantou/typescript-template-language-service-decorator": "^2.3.4",
|
|
19
19
|
"@mantou/vscode-css-languageservice": "^6.3.3",
|
|
20
20
|
"@mantou/vscode-emmet-helper": "^2.9.3",
|
|
21
21
|
"@mantou/vscode-html-languageservice": "^5.3.6",
|
|
22
|
-
"duoyun-ui": "^2.2.
|
|
22
|
+
"duoyun-ui": "^2.2.1",
|
|
23
23
|
"vscode-languageserver-textdocument": "^1.0.12",
|
|
24
24
|
"vscode-languageserver-types": "^3.17.5"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@gemjs/config": "^2.1.
|
|
27
|
+
"@gemjs/config": "^2.1.1",
|
|
28
28
|
"typescript": "^5.6.2"
|
|
29
29
|
},
|
|
30
30
|
"author": "mantou132",
|