@ktjs/ts-plugin 0.1.0
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/README.md +86 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.mjs +1 -0
- package/package.json +42 -0
package/README.md
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# @ktjs/ts-plugin
|
|
2
|
+
|
|
3
|
+
TypeScript language service plugin for KT.js `k-for` scope variables in TSX.
|
|
4
|
+
|
|
5
|
+
## What it does
|
|
6
|
+
|
|
7
|
+
- Editor-only enhancement (tsserver), no runtime transform.
|
|
8
|
+
- Suppresses TS2304 (`Cannot find name ...`) for aliases declared by `k-for`.
|
|
9
|
+
- Supports Vue-like syntax:
|
|
10
|
+
- `k-for="item in list"`
|
|
11
|
+
- `k-for="(item, i) in list"`
|
|
12
|
+
- `k-for="(value, key, i) in mapLike"`
|
|
13
|
+
- Keeps legacy fallback mode:
|
|
14
|
+
- `k-for={list}` with `k-for-item` / `k-for-index` (or configured defaults).
|
|
15
|
+
|
|
16
|
+
## Install
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
pnpm add -D @ktjs/ts-plugin typescript
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Where to install it
|
|
23
|
+
|
|
24
|
+
Install it in the same project/workspace that owns the `tsconfig.json` where you enable the plugin.
|
|
25
|
+
|
|
26
|
+
- Single-package app: install in that app.
|
|
27
|
+
- Monorepo: install in each package that has its own TSX `tsconfig` and needs this behavior, or install at repo root if your package manager hoists and the editor can resolve it.
|
|
28
|
+
|
|
29
|
+
If VS Code still does not load the plugin, make sure it uses your workspace TypeScript version.
|
|
30
|
+
|
|
31
|
+
## tsconfig usage
|
|
32
|
+
|
|
33
|
+
```json
|
|
34
|
+
{
|
|
35
|
+
"compilerOptions": {
|
|
36
|
+
"plugins": [
|
|
37
|
+
{
|
|
38
|
+
"name": "@ktjs/ts-plugin"
|
|
39
|
+
}
|
|
40
|
+
]
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Optional config
|
|
46
|
+
|
|
47
|
+
```json
|
|
48
|
+
{
|
|
49
|
+
"compilerOptions": {
|
|
50
|
+
"plugins": [
|
|
51
|
+
{
|
|
52
|
+
"name": "@ktjs/ts-plugin",
|
|
53
|
+
"forAttr": "k-for",
|
|
54
|
+
"itemAttr": "k-for-item",
|
|
55
|
+
"indexAttr": "k-for-index",
|
|
56
|
+
"itemName": "item",
|
|
57
|
+
"indexName": "index",
|
|
58
|
+
"allowOfKeyword": true
|
|
59
|
+
}
|
|
60
|
+
]
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Example
|
|
66
|
+
|
|
67
|
+
```tsx
|
|
68
|
+
const users = [{ id: 1, name: 'A' }];
|
|
69
|
+
|
|
70
|
+
const view = (
|
|
71
|
+
<li k-for="(user, i) in users" k-key="user.id">
|
|
72
|
+
{i + 1}. {user.name}
|
|
73
|
+
</li>
|
|
74
|
+
);
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Without this plugin, `user` / `i` are often reported as undefined by the TypeScript language service in TSX.
|
|
78
|
+
|
|
79
|
+
## Official docs
|
|
80
|
+
|
|
81
|
+
This package itself currently has no standalone official website doc page. The canonical usage guide is this README.
|
|
82
|
+
|
|
83
|
+
For TypeScript plugin mechanics, see official docs:
|
|
84
|
+
|
|
85
|
+
- TSConfig `plugins`: https://www.typescriptlang.org/tsconfig/#plugins
|
|
86
|
+
- Writing a language service plugin: https://github.com/microsoft/TypeScript/wiki/Writing-a-Language-Service-Plugin
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { }
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
package/package.json
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ktjs/ts-plugin",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "TypeScript language service plugin for kt.js k-for scope names in TSX.",
|
|
5
|
+
"type": "commonjs",
|
|
6
|
+
"main": "./dist/index.cjs",
|
|
7
|
+
"types": "./dist/index.d.cts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.cts",
|
|
11
|
+
"require": "./dist/index.cjs",
|
|
12
|
+
"default": "./dist/index.cjs"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist"
|
|
17
|
+
],
|
|
18
|
+
"keywords": [
|
|
19
|
+
"typescript",
|
|
20
|
+
"tsserver",
|
|
21
|
+
"language-service",
|
|
22
|
+
"plugin",
|
|
23
|
+
"kt.js",
|
|
24
|
+
"k-for"
|
|
25
|
+
],
|
|
26
|
+
"license": "MIT",
|
|
27
|
+
"author": {
|
|
28
|
+
"name": "Kasukabe Tsumugi",
|
|
29
|
+
"email": "futami16237@gmail.com"
|
|
30
|
+
},
|
|
31
|
+
"repository": {
|
|
32
|
+
"type": "git",
|
|
33
|
+
"url": "https://github.com/baendlorel/kt.js",
|
|
34
|
+
"directory": "packages/ts-plugin"
|
|
35
|
+
},
|
|
36
|
+
"peerDependencies": {
|
|
37
|
+
"typescript": ">=5.0.0"
|
|
38
|
+
},
|
|
39
|
+
"scripts": {
|
|
40
|
+
"build": "tsc -p tsconfig.json"
|
|
41
|
+
}
|
|
42
|
+
}
|