You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{functiontest(args: {hogehoge?: string;}){console.log(args);// expect => hogehoge is (string | undefined)console.log(args.hogehoge);console.log(typeofargs.hogehoge);}test({hogehoge: "aaaa",});{consta: {[key: string]: number}={"hogehoge": 10,"umauma": 10,};// it looks => hogehoge is (number | undefined)console.log(a["hogehoge"]);console.log(typeofa["hogehoge"]);// Contrary to expectations, no error occurs// Same with "noPropertyAccessFromIndexSignature" set to "false"test(a);}{consta: Record<string,number>={"hogehoge": 10,"umauma": 10,};// it looks => hogehoge is (number | undefined)console.log(a["hogehoge"]);console.log(typeofa["hogehoge"]);// Contrary to expectations, no error occurstest(a);}{consta={"hogehoge": 10,"umauma": 10,};console.log(a["hogehoge"]);console.log(typeofa["hogehoge"]);// If the property name is specified explicitly, the error occurs as expected.test(a);}}
π Actual behavior
See code comments above.
π Expected behavior
See code comments above.
Additional information about the issue
When specifying a partial object as a function argument,
it is possible to call the function with variables defined by index signatures
(different types than the function argument).
π Search Terms
function argument
partial object
index signatures
π Version & Regression Information
What I've tried in the Playground
5.8.0-dev.20241119
5.6.3 <-- This is my development environment version
3.3.3
β― Playground Link
https://www.typescriptlang.org/play/?ts=5.8.0-dev.20241119#code/N4KABBYGYK4HYGMAuBLA9nMSCmBnJAFAIYBOA5rgFxiiR1gAWaZ2TLA-NfiSnGQNzhIAXwCUNIfTAIMuNABtsAOnnNi5XKMGT6Ael1hsADwAO2ZGAC8APkbNW9sClxgC3XmTAAfMPAAm2FC82H6iOnQycHKKKmqkFEpsDixa4ZCR0cqqZARIAJ5maFBg8biJ9kmpdMIgOjj4BLRSdixJ1ABERF1E7QA0OmLadE1SGUgl1MBgANoA1th5XEg8fAC61HAwALYARtgkYMJWEs307UlJ7dQAjAAM-ad07dtEL1dgdw-NwkPN+k7jVRoWYuGwtZLYJwuAibXb7by+OABIJwEJhU4ZBRZOLTc4VeztVZVZqYmLZXIFbBFEq4i4EomCU5pCD-ADCGGWpDyWDQhlM5iQRFQsl6YDgvP2JDQBzQCAQMBIuGZYH+AGUiFtIQB3FBIBhgdrigAKUrMJHyAEE5XhcAAxKVbACSSOMqpQZDgQoV2HaYFw2HGSF57SgRHk-vayvqhCIxIgNR0I3oYwmYAASuZpX4ADzuPii2F7Ei2SwnR4QPGtAk3e7Kp4vN41r5SH61U7-XVgIEgqy2OksKGuQvwnz+QLBULK0nYnJEWn4liEuPJ2RY2I5fKFYpzysQpeM5rKtkckhcnl8szIIXoKIFiUkKUyuUKpWnaPEZcJ4ZT2TjIjHJNTl3S4mzrSBni2V5IPeT5lVbH8ojXckd37H0GQQzJ1wpLcaWA+lUiPAxHWKPVIRMU19nyMUNUhZw-UvFAghCC95BQBBdXkPJRVIwwH2lMBZXlRUShcYxLxwPwlCjPAY0-EAaiAA
π» Code
π Actual behavior
See code comments above.
π Expected behavior
See code comments above.
Additional information about the issue
When specifying a partial object as a function argument,
it is possible to call the function with variables defined by index signatures
(different types than the function argument).
Below is the tsconfig.json I am using
The text was updated successfully, but these errors were encountered: