Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance: TypeScriptの型を厳格化 #891

Open
wants to merge 21 commits into
base: master
Choose a base branch
from

Conversation

takejohn
Copy link
Contributor

What

  • as!による型アサーションを減らします。
  • CharStreameofcharがgetterであるために意図しないnarrowingが発生していたので通常のメソッドに変更します。
  • パーサのプラグインで用いるvisitNode関数にジェネリクスを使用します。
  • Ast.Forの型を変更し、(varおよびfrom, to)またはtimesのどちらかが必須となるようにします。
  • Tokenの型を変更し、識別子やリテラルの場合はvalueを、テンプレートリテラルの場合はchildrenを必須にします。

Why

Resolve #880

Additional info (optional)

@codecov-commenter
Copy link

codecov-commenter commented Dec 31, 2024

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

Attention: Patch coverage is 98.93238% with 3 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/error.ts 66.66% 2 Missing ⚠️
src/interpreter/index.ts 96.96% 1 Missing ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Files with missing lines Coverage Δ
src/interpreter/primitive-props.ts 98.07% <100.00%> (+0.09%) ⬆️
src/interpreter/scope.ts 93.69% <100.00%> (+3.15%) ⬆️
src/node.ts 85.71% <ø> (-12.66%) ⬇️
src/parser/plugins/validate-jump-statements.ts 100.00% <100.00%> (ø)
src/parser/plugins/validate-keyword.ts 95.67% <100.00%> (+7.06%) ⬆️
src/parser/plugins/validate-type.ts 100.00% <100.00%> (+17.64%) ⬆️
src/parser/scanner.ts 95.22% <100.00%> (+6.46%) ⬆️
src/parser/streams/char-stream.ts 90.47% <100.00%> (+1.98%) ⬆️
src/parser/streams/token-stream.ts 79.62% <ø> (+16.18%) ⬆️
src/parser/syntaxes/common.ts 96.82% <100.00%> (+7.29%) ⬆️
... and 9 more

... and 13 files with indirect coverage changes

var: string; // イテレータ変数名
from: Expression; // 開始値
to: Expression; // 終値
} | {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
} | {
} | {
var: string; // イテレータ変数名

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

vartimesが同時に定義されることはないと思います。
for let i, 10 {}from = 0, to = 10になりますし

src/parser/visit.ts Outdated Show resolved Hide resolved
Co-authored-by: salano_ym <53254905+salano-ym@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TypeScriptの型を考え直す
5 participants