Title: Incorrect type inferrence for default-initialized parameters and noImplicitAny · Issue #36052 · microsoft/TypeScript · GitHub
Open Graph Title: Incorrect type inferrence for default-initialized parameters and noImplicitAny · Issue #36052 · microsoft/TypeScript
X Title: Incorrect type inferrence for default-initialized parameters and noImplicitAny · Issue #36052 · microsoft/TypeScript
Description: Having a default initialized parameter in a function declaration passed to a function incorrectly asserts that the parameter is an any type TypeScript Version: 3.7.4 (also reproduced on Nightly) I recently upgraded from Typescript 3.5.2 ...
Open Graph Description: Having a default initialized parameter in a function declaration passed to a function incorrectly asserts that the parameter is an any type TypeScript Version: 3.7.4 (also reproduced on Nightly) I ...
X Description: Having a default initialized parameter in a function declaration passed to a function incorrectly asserts that the parameter is an any type TypeScript Version: 3.7.4 (also reproduced on Nightly) I ...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/36052
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Incorrect type inferrence for default-initialized parameters and noImplicitAny","articleBody":"\u003c!-- 🚨 STOP 🚨 𝗦𝗧𝗢𝗣 🚨 𝑺𝑻𝑶𝑷 🚨\r\n\r\nHalf of all issues filed here are duplicates, answered in the FAQ, or not appropriate for the bug tracker. Even if you think you've found a *bug*, please read the FAQ first, especially the Common \"Bugs\" That Aren't Bugs section!\r\n\r\nPlease help us by doing the following steps before logging an issue:\r\n * Search: https://github.com/Microsoft/TypeScript/search?type=Issues\r\n * Read the FAQ: https://github.com/Microsoft/TypeScript/wiki/FAQ\r\n\r\nPlease fill in the *entire* template below.\r\n-->\r\nHaving a default initialized parameter in a function declaration passed to a function incorrectly asserts that the parameter is an `any` type\r\n\u003c!--\r\nPlease try to reproduce the issue with the latest published version. It may have already been fixed.\r\nFor npm: `typescript@next`\r\nThis is also the 'Nightly' version in the playground: http://www.typescriptlang.org/play/?ts=Nightly\r\n-->\r\n**TypeScript Version:** \r\n3.7.4 (also reproduced on Nightly)\r\nI recently upgraded from Typescript 3.5.2 to 3.7.3. The code below was fine with ts 3.5.2\r\n\u003c!-- Search terms you tried before logging this (so others can find this issue more easily) -->\r\n\r\n**Search Terms:**\r\ndefault parameter noImplicitAny\r\n**Code**\r\n\r\n```ts\r\nfunction execute(script: string | Function): Promise\u003cstring> {\r\n return new Promise((resolve, reject) => {\r\n if (typeof script === 'string') {\r\n reject('rejecting promise');\r\n }\r\n resolve('resolving promise');\r\n });\r\n}\r\n\r\nexport function executeSomething() {\r\n return execute((root: HTMLElement, debug = true) => {\r\n if (debug) {\r\n root.innerHTML = '';\r\n }\r\n });\r\n}\r\n```\r\n\r\n**Expected behavior:**\r\nNo Errors\r\n\r\n**Actual behavior:**\r\nI get an error for the `debug = true` statement. \"TS7006: Parameter 'debug' implicitly has an 'any' type.\"\r\n\r\n**Playground Link:** \r\n[Playground link](http://www.typescriptlang.org/play/?ts=3.8.0-dev.20200104#code/GYVwdgxgLglg9mABAUwB7IiKyAUBnCAJxgAcoAuRPKYsAc0QB9EAxcaeMASkoAVC4AWxh5kAHmq06APkQBvAFCJEhZFBCEkYZAHdE-ISNw5VeOABsAbsgA0K5ACsMULogC8sxcuUxgiHFAAniTIcH4ExGTubm6IAOSSMPRxrl7eyqpO0Dhxmc5JDCQCwqIpANxK3gC+lRnIZla4ufUWlgWIRYalXBXKVT0KNQpoJHCEUIigkLAIKOiY2ADKQmoAFgU4qZWq6ppzGFjGAnAUiAASACoAsgAyAKLmyILIYFB2ACbIAEYgDLE0IGQrg88lqiF8-k+PzoW3SGTgJwAdEltIRLrd3PE4r1qpV+hUqkA)\r\n\r\n**Related Issues:** \r\nNone\r\n","author":{"url":"https://github.com/dave-hart","@type":"Person","name":"dave-hart"},"datePublished":"2020-01-07T08:48:21Z","url":"https://github.com/microsoft/TypeScript/issues/36052"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:9f367607-1542-e078-b50e-df18c14586e4 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CF30:EDA7A:2BD5F94:37B31EB:6B01B15A |
| html-safe-nonce | d437b5c96042113688fb314ced7f4a3fb4da77c00795697a616d0e9f2d0020e7 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDRjMwOkVEQTdBOjJCRDVGOTQ6MzdCMzFFQjo2QjAxQjE1QSIsInZpc2l0b3JfaWQiOiI4NjY0ODI4NzgxODAzOTc1MDAyIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 20f017d7ff79a2c2b274283493100bd7e6b4b5a0eeb302b78bebc40b4cc86e6f |
| hovercard-subject-tag | issue:546155970 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/microsoft/TypeScript/36052/issue_layout |
| twitter:image | https://opengraph.githubassets.com/d86ca1b0fe83425de97b34474b0563c67925ad5232e48a791575cfef05b9df2b/microsoft/TypeScript/issues/36052 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/d86ca1b0fe83425de97b34474b0563c67925ad5232e48a791575cfef05b9df2b/microsoft/TypeScript/issues/36052 |
| og:image:alt | Having a default initialized parameter in a function declaration passed to a function incorrectly asserts that the parameter is an any type TypeScript Version: 3.7.4 (also reproduced on Nightly) I ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | dave-hart |
| hostname | github.com |
| expected-hostname | github.com |
| None | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| turbo-cache-control | no-preview |
| go-import | github.com/microsoft/TypeScript git https://github.com/microsoft/TypeScript.git |
| octolytics-dimension-user_id | 6154722 |
| octolytics-dimension-user_login | microsoft |
| octolytics-dimension-repository_id | 20929025 |
| octolytics-dimension-repository_nwo | microsoft/TypeScript |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 20929025 |
| octolytics-dimension-repository_network_root_nwo | microsoft/TypeScript |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 8c77c9e8439031ad54c75a250694842892f693e1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width