Multi-line top-level `await` causes duplicate declaration error
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 45/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
- 技術スタック
- typescript
- 領域
- compilers
調査の方向性
リンクされている TypeScript Playground の再現例から始め、報告された重複 BitSet 診断に関するコンパイラの top-level-await とモジュール分析を調査してください。空のモジュール宣言がある場合でもない場合でも、サンプルが重複識別子エラーと private メンバー非互換エラーのどちらも生成しなくなれば完了です。
索引モデルが issue の本文から書いたものです。
説明
🔎 Search Terms
typescript top-level await export class "duplicate identifier"
🕗 Version & Regression Information
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about await, identifiers, modules
⏯ Playground Link
💻 Code
`
(module
(func (export "i64.popcnt") (param i64) (result i32)
local.get 0
i64.popcnt
i32.wrap_i64))
`
// via https://webassembly.github.io/wabt/demo/wat2wasm/
const wasm = (await
WebAssembly.instantiateStreaming(
fetch("data:application/wasm;base64,AGFzbQEAAAABBgFgAX4BfwMCAQAHDgEKaTY0LnBvcGNudAAACggBBgAgAHunCwAKBG5hbWUCAwEAAA=="),
{}));
const instance = wasm.instance;
export const popcount = instance.exports['i64.popcnt'] as (v: bigint) => number;
export class BitSet {
#grow(){}
}
// module uncomment_me_to_fix {}
🙁 Actual behavior
Line 17 (export class BitSet) reports an error: Duplicate identifier 'BitSet'.(2300)
As far as I can see there's no duplicate identifier; suppressing that line with a @ts-expect-error produces a strange result that the exported BitSet is unusable when imported into a different module, whereupon Typescript reports:
Type 'import("./lib/bitset").BitSet' is not assignable to type 'import("./lib/bitset").BitSet'. Two different types with this name exist, but they are unrelated.
Property '#grow' in type 'BitSet' refers to a different member that cannot be accessed from within type 'BitSet'.ts(2719)
Uncommenting the empty module definition at the bottom of the file appears to collapse the superimposed wave function of BitSet, and renders the type singular again.
🙂 Expected behavior
To see neither error, whether or not there's a module in the same file.
Additional information about the issue
Hopefully, it's clear enough from the example what I'm hoping to do here with the top-level await; I deleted all the method bodies for brevity, so you'll have to trust me when I say popcount is a very useful primitive to have.
I did spend a fair bit of time looking for suggestions on whether I'm holding the tool wrong with the await ....; export class ... sequencing, but as far as I can tell that is how it's intended to be used. The fact that an unrelated (to my eye, anyway) expression later on in the file changes the compiler's report is what finally moved me to file an issue against tsc here.
Thanks for all your work on Typescript!
- 主要言語
- Go
- スター
- 111k
- フォーク
- 14.4k
- 平均マージ
- 1日 19時間
- マージ済み PR(30日)
- 117
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
microsoft/TypeScript のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
microsoft/TypeScript#64322 · コメント 2 件 · リアクション 1 件 · 担当者 2 名 ·
-
Possible Improvement
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
microsoft/TypeScript#64278 · コメント 1 件 · リアクション 1 件 ·
-
Docs
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
microsoft/TypeScript#64118 · コメント 1 件 ·
-
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
microsoft/TypeScript#64094 ·
-
Docs
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
microsoft/TypeScript#63959 · コメント 5 件 ·
microsoft/TypeScript の issue をすべて見る
似ている issue
-
kind/bug
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
kubernetes-sigs/prow#953 · コメント 1 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
caddyserver/caddy#8046 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
-
L1 recommended for recruits
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
-
area/entangle bug
難易度 1/5 1時間未満 初心者へのやさしさ 92/100