Repository navigation
docs(web): UInput の属性コメントから誤った一般則を取り除く - #90
Merged
Merged
Conversation
special-invoice.vue の `<UInput>` 前のコメントは「`UInput` がタグで受け取るのは
@nuxt/ui の `Pick` が挙げている HTML 属性の名前だけである」と書いていたが、これは
誤りだった。両方向に反例がある。
このコメントを読んだ人は、`Pick` の列挙を見て `UInput` がタグで受け取る名前を判定
しようとして誤る。そのため、列挙から名前を言い当てる規則そのものを書かない形に
改めた。型定義の事実、すなわち @nuxt/ui が `dist/runtime/types/html.d.ts` で Vue の
型から `Pick` した自前の `InputHTMLAttributes` を宣言し、`InputProps` が
`/** @vue-ignore */ Omit<…>` でそれを継承していることは残し、そこから受け取る名前を
導く記述を削った。タグの検査対象は @nuxt/ui が宣言する prop より広く、エラー
メッセージが `VNodeProps & AllowedComponentProps & ComponentCustomProps & { … }` と
名指しする。
実測の範囲。2026-09-20 に、このコミットの分岐元 c81574a の作業ツリー(@nuxt/ui
4.11.1、vue-tsc 3.3.11)で、`apps/web/.nuxt/tsconfig.app.json` を継承し `files` に
SFC を 1 本だけ挙げた tsconfig に対して `vue-tsc --noEmit` を実行した。1 ケース
1 ファイルで分離し、`import UInput from '@nuxt/ui/components/Input.vue'` で読み込み、
Nuxt の自動 import が効かないので `ref` は vue から明示的に import した。
`strictTemplates` と `fallthroughAttributes` はいずれも true である
(nuxt.config.ts)。結果は次のとおりで、`Pick` の列挙は両方向とも結果を予測しない。
- `style="color:red"` / `class="c"` / `id="x"` / `:enterKeyHint="'go'"` /
`readonly` / `maxlength="4"` / `v-bind="{ inputmode: 'numeric' }"` はエラー 0
- `enterkeyhint="go"` は TS2561
- `inputmode="numeric"` と、陰性対照の `bogusattr="x"` は TS2353
`style` は `Pick` の列挙に無く、`Input.vue.d.ts` にも現れない(同じ作業ツリーで
`grep -c style` が 0)が、タグに書ける。`enterkeyhint` は `Pick` が TS の名前
`enterKeyHint` を持つのに、HTML の綴りでは拒否される。
一般則を書かない理由。列挙から受け取る名前を導く規則には、仕様にも実装にも根拠が
得られなかった。手元で確かめたケースが何件通っても一般則の根拠にはならないので、
確かめた範囲だけを書いた。
描画は確かめていない。`.vue` の描画を確かめる手段がリポジトリに無いためで、その事実
もコメントに書いた(#57)。`inheritAttrs: false` と、内側の `<input>` の
`v-bind="{ ...$attrs, ...ariaAttrs }"` と、`defineProps` に `inputmode` /
`readonly` / `maxlength` が無いことは、インストール済みの `Input.vue` を読んで
確かめた。
コメントの言語は英語のまま残した。このファイルのコメントは全て英語で、日本語への
統一は #54 が対象として挙げている。ここで 1 箇所だけ日本語にすると、ファイルの中で
言語が混ざり、#54 の作業と二重になる。
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
何を直すか
apps/web/app/pages/special-invoice.vueの<UInput>の直前のコメントが、両方向に反例を持つ一般則を書いていた。このコメントを読んだ人は、
Pickの列挙を見てUInputがタグで受け取る名前を判定しようとして誤る。列挙から名前を言い当てる規則そのものを書かない形に改めた。反例
2026-09-20 に、分岐元
c81574aの作業ツリー (@nuxt/ui4.11.1、vue-tsc3.3.11) で、apps/web/.nuxt/tsconfig.app.jsonを継承しfilesに SFC を 1 本だけ挙げた tsconfig に対してvue-tsc --noEmitを実行した。1 ケース 1 ファイルで分離し、import UInput from '@nuxt/ui/components/Input.vue'で読み込んだ。strictTemplatesとfallthroughAttributesはいずれもtrueである (nuxt.config.ts)。style="color:red"/class="c"/id="x"/:enterKeyHint="'go'"/readonly/maxlength="4"/v-bind="{ inputmode: 'numeric' }"enterkeyhint="go"TS2561inputmode="numeric"/bogusattr="x"(陰性対照)TS2353styleはPickの列挙に無く、Input.vue.d.tsにも現れない (同じ作業ツリーでgrep -c styleが 0) が、タグに書ける。enterkeyhintはPickが TS の名前enterKeyHintを持つのに、HTML の綴りでは拒否される。エラーメッセージが名指しする型は
VNodeProps & AllowedComponentProps & ComponentCustomProps & { … }で、@nuxt/uiが宣言する prop より広い。 コメントにはこの逐語を入れてある。なぜ一般則を書かないか
列挙から受け取る名前を導く規則には、仕様にも実装にも根拠が得られなかった。 手元で確かめたケースが何件通っても一般則の根拠にはならないので、確かめた範囲だけを書いた。
この規則は 3 回書き直されて 3 回とも反例に当たっている。 v1「直接宣言されている prop だけ」、v2「
Pickの列挙にある名前だけ」、v3 (c81574aでマージされたもの)「Pickが挙げている HTML 属性の名前だけ」。共通点は、ライブラリの配布物を読んで得た結論を規則として書いたことである。測定で確かめた入出力は毎回正しく、崩れたのは常に「なぜそうなるか」を配布物の中身から説明しようとした部分だった。確かめていないこと
描画は確かめていない。
.vueの描画を確かめる手段がリポジトリに無いためで (#57)、その事実もコメントに書いた。inheritAttrs: falseと、内側の<input>のv-bind="{ ...$attrs, ...ariaAttrs }"と、definePropsにinputmode/readonly/maxlengthが無いことは、インストール済みのInput.vueを読んで確かめた。コメントの言語
英語のまま残した。 このファイルのコメントは全て英語で、日本語への統一は #54 が対象として挙げている。ここで 1 箇所だけ日本語にすると、ファイルの中で言語が混ざり、#54 の作業と二重になる。
git diff --name-status 293a57e...d8feacaの追加にこのファイルが含まれ、#54 のコメント行の条件に当たる行がd8feaca時点で 7 行あることを確かめてある。#54 の担当への申し送り: この段落を翻訳する際に、測定条件 (版番号・日付) と「一般則を書かない」という趣旨を落とさないこと。要約すると 4 回目の全称命題に戻る。
確認
pnpm lint/pnpm knip/pnpm typecheck/pnpm test/pnpm buildがすべて終了コード 0。🤖 Generated with Claude Code