microsoft / microsoft/TypeScript
Missing property incompatible error when there is a namespace with a value export
Nessuno ha ancora preso questa issue.
- Lingua principale
- Go
- Stelle
- 111k
- Fork
- 14.4k
- Merge medio
- 1g 19h
- PR unite (30g)
- 117
Descrizione
Bug Report
🔎 Search Terms
index signature, namespace
🕗 Version & Regression Information
- This is the behavior in every version I tried: v4.9.4, v5.0.4
⏯ Playground Link
Playground link with relevant code
💻 Code
interface Dict {
[key: string]: unknown;
}
interface Thing {}
interface ThingWithNamespaceWithValueExport {}
namespace ThingWithNamespaceWithValueExport {
export const asdasd: string = '';
}
interface ThingWithNamespaceWithTypeExport {}
namespace ThingWithNamespaceWithTypeExport {
export type asdasd = string;
}
interface Foo {
prop?: Dict;
}
interface Bar extends Foo {
// ~~~ Interface 'Bar' incorrectly extends interface 'Foo'. Types of property 'prop' are incompatible. Type 'Thing' is not assignable to type 'Dict'. Index signature for type 'string' is missing in type 'Thing'.
prop: Thing;
}
interface Baz extends Foo {
// No error here. But I would expect the same error.
prop: ThingWithNamespaceWithValueExport;
}
interface Quux extends Foo {
// ~~~~ Interface 'Quux' incorrectly extends interface 'Foo'. Types of property 'prop' are incompatible. Type 'ThingWithNamespaceWithTypeExport' is not assignable to type 'Dict'. Index signature for type 'string' is missing in type 'ThingWithNamespaceWithTypeExport'.
prop: ThingWithNamespaceWithTypeExport;
}
🙁 Actual behavior
No error for interface Baz, where prop is the type of an interface with a namespace, which exports a value.
🙂 Expected behavior
Same error for Baz that we get for Bar and Quux.
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia con il TypeScript Playground collegato e confronta le diagnosi per Bar, Baz e Quux. Traccia il percorso di compatibilità dei tipi per un’interface unita a un namespace che esporta un valore; il lavoro è completato quando Baz segnala lo stesso errore di index-signature incompatibile di Bar e Quux.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- typescript
- Ambito
- compilers
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Specificata chiaramente
- Idoneità per principianti
- 42/100