Title: Case that infering type for parameters works for 3.3.0 but error in 3.4.0 · Issue #30840 · microsoft/TypeScript · GitHub
Open Graph Title: Case that infering type for parameters works for 3.3.0 but error in 3.4.0 · Issue #30840 · microsoft/TypeScript
X Title: Case that infering type for parameters works for 3.3.0 but error in 3.4.0 · Issue #30840 · microsoft/TypeScript
Description: TypeScript Version: 3.4.0-dev.201xxxxx Search Terms: 3.4.0 regression parameter type infer Code // with compilerOptions.noImplicitAny=true in tsconfig.json export function test(options: { partial: Partial
| undefined }) { const fn:...
Open Graph Description: TypeScript Version: 3.4.0-dev.201xxxxx Search Terms: 3.4.0 regression parameter type infer Code // with compilerOptions.noImplicitAny=true in tsconfig.json export function test(options: { partia...
X Description: TypeScript Version: 3.4.0-dev.201xxxxx Search Terms: 3.4.0 regression parameter type infer Code // with compilerOptions.noImplicitAny=true in tsconfig.json export function test<S>(options: { ...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/30840
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Case that infering type for parameters works for 3.3.0 but error in 3.4.0","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\n\r\n\u003c!-- Please try to reproduce the issue with `typescript@next`. It may have already been fixed. -->\r\n**TypeScript Version:** 3.4.0-dev.201xxxxx\r\n\r\n\u003c!-- Search terms you tried before logging this (so others can find this issue more easily) -->\r\n**Search Terms:**\r\n\r\n3.4.0 regression\r\nparameter type infer\r\n\r\n**Code**\r\n\r\n```ts\r\n// with compilerOptions.noImplicitAny=true in tsconfig.json\r\nexport function test\u003cS>(options: { partial: Partial\u003cS> | undefined }) {\r\n const fn: any = function (state = options.partial, action_: any) {\r\n return state\r\n }\r\n return fn\r\n}\r\n```\r\nThe related tsconfig.json\r\n```json\r\n{\r\n \"compilerOptions\": {\r\n \"target\": \"es5\",\r\n \"lib\": [\"dom\", \"dom.iterable\", \"esnext\"],\r\n \"noImplicitAny\": true,\r\n \"noImplicitReturns\": true,\r\n \"allowJs\": true,\r\n \"skipLibCheck\": true,\r\n \"esModuleInterop\": true,\r\n \"allowSyntheticDefaultImports\": true,\r\n \"strict\": true,\r\n \"forceConsistentCasingInFileNames\": true,\r\n \"module\": \"esnext\",\r\n \"moduleResolution\": \"node\",\r\n \"resolveJsonModule\": true,\r\n \"isolatedModules\": true,\r\n \"noEmit\": true,\r\n \"jsx\": \"preserve\"\r\n },\r\n \"include\": [\"src\"]\r\n}\r\n```\r\n\r\n**Expected behavior:**\r\nNo error. It's worth noting that it works in 3.3.4.\r\n\r\n**Actual behavior:**\r\n\r\nWith the `tsc` command line, it outputs the following errors:\r\n\r\n```\r\nerror TS7006: Parameter 'state' implicitly has an 'any' type.\r\n\r\n25 const fn: any = function(state = options.partial, action_: any) {\r\n```\r\n\r\n**Playground Link:** \u003c!-- A link to a TypeScript Playground \"Share\" link which demonstrates this behavior -->\r\n\r\n**Related Issues:** \u003c!-- Did you find other bugs that looked similar? -->\r\n\r\n\u003chr />\r\n\r\nThe code works in 3.3.4 with no errors, but after upgrading to 3.4.0, the tsc complains that the parameter has 'any' type when the __LHS__ `fn` is of any type. If I replace `fn: any = ` with `fn =`, it works for 3.4.0.","author":{"url":"https://github.com/TerenceZ","@type":"Person","name":"TerenceZ"},"datePublished":"2019-04-10T01:40:59Z","url":"https://github.com/microsoft/TypeScript/issues/30840"}
| 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:e752e392-f314-9400-f630-71f0294cce40 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 80C2:3DD488:2B4A46C:3706C0E:6B01B166 |
| html-safe-nonce | dcc8dfb332ec8cdcd181c793615fe85d5df6fafed7606aed25f599b9d1f1af3c |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4MEMyOjNERDQ4ODoyQjRBNDZDOjM3MDZDMEU6NkIwMUIxNjYiLCJ2aXNpdG9yX2lkIjoiNDE2MTQwODg4NTkyOTkxNDcyNiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 53c0310f5463f72f63757514b3559657501ec0a65adfef96fa9808d8e288ad40 |
| hovercard-subject-tag | issue:431265280 |
| 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/30840/issue_layout |
| twitter:image | https://opengraph.githubassets.com/2470134544fa121795af782d21314a45f05087ba6bd9d494fe4315c0862e422a/microsoft/TypeScript/issues/30840 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/2470134544fa121795af782d21314a45f05087ba6bd9d494fe4315c0862e422a/microsoft/TypeScript/issues/30840 |
| og:image:alt | TypeScript Version: 3.4.0-dev.201xxxxx Search Terms: 3.4.0 regression parameter type infer Code // with compilerOptions.noImplicitAny=true in tsconfig.json export function test |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | TerenceZ |
| 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