-
Notifications
You must be signed in to change notification settings - Fork 13k
Open
Labels
Awaiting More FeedbackThis means we'd like to hear from more people who would be helped by this featureThis means we'd like to hear from more people who would be helped by this featureSuggestionAn idea for TypeScriptAn idea for TypeScript
Description
Bug Report
π Search Terms
noPropertyAccessFromIndexSignature
π Version & Regression Information
4.2+
- This is the behavior in every version I tried
β― Playground Link
π» Code
let test: {[index:string]:string} = {
// we want this to be caught by noPropertyAccessFromIndexSignature, but it isn't.
abc: 'hi',
def: 'hello',
};
console.log(test.abc); // reported
console.log(test.def); // reported
console.log(test['abc']); // OK
console.log(test['def']); // OK
π Actual behavior
Unquoted string keys are allowed when assigned to types with index signatures.
π Expected behavior
Some mechanism for restricting the definitions of object literals so that only named properties are allowed to be provided without quotes ( {['somekey']: value}
or {'somekey':value}
. This would both prevent logic errors and improve compatibility with Closure Compiler's ADVANCED optimizations.
ReinisV
Metadata
Metadata
Assignees
Labels
Awaiting More FeedbackThis means we'd like to hear from more people who would be helped by this featureThis means we'd like to hear from more people who would be helped by this featureSuggestionAn idea for TypeScriptAn idea for TypeScript