-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Closed
Labels
In DiscussionNot yet reached consensusNot yet reached consensusSuggestionAn idea for TypeScriptAn idea for TypeScript
Description
Search Terms
type check
Suggestion
As https://gist.github.com/RyanCavanaugh/f80f9ddc50d45c4d76e7c4101efada28 said.
To turn off allowing
expr.propwhen expr just has a string index signature.
But does it's better if only issue errors when property access referenced to signature?
Examples
interface A {
foo: string
}
interface B {
[k: string]: string
}
interface C {
foo: string
[k: string]: string
}
declare const a: A;
declare const b: B;
declare const c: C;
declare const d: C | undefined;
a.foo;
a["foo"]
b.foo; // error
b["foo"];
c.foo;
c["foo"]
c.bar; // error
c["bar"];
d?.foo;
d?.["foo"]
d?.bar; // error
d?.["bar"];Checklist
My suggestion meets these guidelines:
- This wouldn't be a breaking change in existing TypeScript/JavaScript code
- This wouldn't change the runtime behavior of existing JavaScript code
- This could be implemented without emitting different JS based on the types of the expressions
- This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, etc.)
- This feature would agree with the rest of TypeScript's Design Goals.
ssledorze, LauraBeatris and Lemminghssledorze, IOuser and LauraBeatris
Metadata
Metadata
Assignees
Labels
In DiscussionNot yet reached consensusNot yet reached consensusSuggestionAn idea for TypeScriptAn idea for TypeScript