René's URL Explorer Experiment


Title: Constructor functions are not recognized as equivalent to classes · Issue #27328 · microsoft/TypeScript · GitHub

Open Graph Title: Constructor functions are not recognized as equivalent to classes · Issue #27328 · microsoft/TypeScript

X Title: Constructor functions are not recognized as equivalent to classes · Issue #27328 · microsoft/TypeScript

Description: TypeScript Version: 3.1.0-dev.20180922 Search Terms: js constructor function Code // clazz1c.js function clazz1c(){ this.constructorOnly = 0 // (1.) [ts] 'this' implicitly has type 'any' because it does not have a type annotation. this.c...

Open Graph Description: TypeScript Version: 3.1.0-dev.20180922 Search Terms: js constructor function Code // clazz1c.js function clazz1c(){ this.constructorOnly = 0 // (1.) [ts] 'this' implicitly has type 'any' because it...

X Description: TypeScript Version: 3.1.0-dev.20180922 Search Terms: js constructor function Code // clazz1c.js function clazz1c(){ this.constructorOnly = 0 // (1.) [ts] 'this' implicitly has type 'any...

Opengraph URL: https://github.com/microsoft/TypeScript/issues/27328

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Constructor functions are not recognized as equivalent to classes","articleBody":"**TypeScript Version:**  3.1.0-dev.20180922\r\n\r\n**Search Terms:**\r\n\r\njs constructor function\r\n\r\n**Code**\r\n\r\n```js\r\n// clazz1c.js\r\nfunction clazz1c(){\r\n\tthis.constructorOnly = 0 // (1.) [ts] 'this' implicitly has type 'any' because it does not have a type annotation.\r\n\tthis.constructorUnknown = undefined // (1.) [ts] 'this' implicitly has type 'any' because it does not have a type annotation.\r\n}\r\n\r\nclazz1c.prototype.method = function() {\r\n\tthis.constructorOnly = 3\r\n\tthis.constructorUnknown = \"plunkbat\"\r\n}\r\n\r\nmodule.exports=clazz1c\r\n```\r\n\r\n```ts \r\n// node-global.ts\r\n/// \u003creference types=\"node\" />\r\nexport {}\r\nimport Clazz1cType = require(\"../clazz1c\") // (2.) (alias) function Clazz1cType(): void\r\nvar clazz1bGlobalVar: Clazz1bType // (2.) var clazz1bGlobalVar: any\r\ndeclare global {\r\n\tnamespace NodeJS {\r\n\t\tinterface Global {\r\n\t\t\tclazz1bGlobalVar: Clazz1cType // (4.) (property) NodeJS.Global.clazz1bGlobalVar: any\r\n\t\t}\r\n\t}\r\n}\r\n```\r\n\r\n```js\r\n// index.js\r\n var clazz1c = require(\"./clazz1c\") // (3.) var clazz1c: typeof clazz1c\r\n var clazz1cInstance = new clazz1c(); // (3.) var clazz1bGlobalVar: any\r\nglobal.clazz1bGlobalVar=clazz1bInstance // (4.) (property) NodeJS.Global.clazz1bGlobalVar: any\r\n```\r\n\r\n```json\r\n// jsconfig.json\r\n{\r\n    \"compilerOptions\": {\r\n\t\t\"allowSyntheticDefaultImports\": true,\r\n\t\t\"checkJs\": true,\r\n\t\t\"noEmit\": true,\r\n\t\t\"module\": \"commonjs\",\r\n\t\t\"moduleResolution\": \"node\",\r\n\t\t\"strict\": true,\r\n\t\t\"noImplicitAny\": true,\r\n\t\t\"noImplicitThis\": true,\r\n\t\t\"target\": \"es5\",\r\n        \"baseUrl\": \".\",\r\n        \"lib\": [\r\n            \"es2015\",\r\n            \"dom\"\r\n\t\t]\r\n\t},\r\n    \"exclude\": [\r\n        \"node_modules\"\r\n    ],\r\n    \"typeAcquisition\": {\r\n        \"enable\": false\r\n    }\r\n}\r\n```\r\n\r\n**Expected behavior:**\r\n1. `this` inside the constructor is infered based on this-property assignments\r\n2. function is recognized as constructor function; assignment gives type of `class`?\r\n3. type equivalent to a class t.i. `(alias) class clazz1c` (per default type is exported too)\r\n4.  typed equivalent to type of constructor function of clazz1c, sth like `new() => clazz1c`?\r\n\r\n**Actual behavior:**\r\n1. `this` inside the constructor is not infered based on this-property assignments\r\n2. function is not recognized as constructor function; assignment gives `any` type\r\n3. type is not recognized as equivalent to a class\r\n4. typed as any\r\n\r\n**Playground Link:** \r\nFor (1) see http://www.typescriptlang.org/play/#src=function%20clazz1c()%7B%0D%0A%09this.constructorOnly%20%3D%200%0D%0A%09this.constructorUnknown%20%3D%20undefined%0D%0A%7D%0D%0A%0D%0Aclazz1c.prototype.method%20%3D%20function()%20%7B%0D%0A%09this.constructorOnly%20%3D%203%0D%0A%09this.constructorUnknown%20%3D%20%22plunkbat%22%0D%0A%09%7D%0D%0A%0D%0Amodule.exports%3Dclazz1c\r\n\r\n(2), (3) and (4) not in playground link, but doable as github tag on request\r\n\r\n**Related Issues:**\r\nNone found\r\n","author":{"url":"https://github.com/joma74","@type":"Person","name":"joma74"},"datePublished":"2018-09-24T22:05:18Z","url":"https://github.com/microsoft/TypeScript/issues/27328"}

react-profiling0
react-import-mapreact,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-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:baf6d6cf-61c1-3e70-4d02-e4e948a8c2b9
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idA1C4:842EC:23DAC2E:2FCEB6D:6B019A3E
html-safe-nonce353a46bba5c036b8d1dd66c2b6cd673b9ad099d3ae8854ebc97215d024cf6e66
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBMUM0Ojg0MkVDOjIzREFDMkU6MkZDRUI2RDo2QjAxOUEzRSIsInZpc2l0b3JfaWQiOiI0NjU2OTU2MDQ5MjY0MzE5MDM4IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmac57b2425322bba428ae86c4712c0d60d414001410bd776a216deef0b62ebfe32a
hovercard-subject-tagissue:363337931
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/microsoft/TypeScript/27328/issue_layout
twitter:imagehttps://opengraph.githubassets.com/4f3025f83ea650de6547be2e2af9d62b487247d8d9056874aa5a81c05b15067c/microsoft/TypeScript/issues/27328
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/4f3025f83ea650de6547be2e2af9d62b487247d8d9056874aa5a81c05b15067c/microsoft/TypeScript/issues/27328
og:image:altTypeScript Version: 3.1.0-dev.20180922 Search Terms: js constructor function Code // clazz1c.js function clazz1c(){ this.constructorOnly = 0 // (1.) [ts] 'this' implicitly has type 'any' because it...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamejoma74
hostnamegithub.com
expected-hostnamegithub.com
Nonecc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c
turbo-cache-controlno-preview
go-importgithub.com/microsoft/TypeScript git https://github.com/microsoft/TypeScript.git
octolytics-dimension-user_id6154722
octolytics-dimension-user_loginmicrosoft
octolytics-dimension-repository_id20929025
octolytics-dimension-repository_nwomicrosoft/TypeScript
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id20929025
octolytics-dimension-repository_network_root_nwomicrosoft/TypeScript
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release8c77c9e8439031ad54c75a250694842892f693e1
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/microsoft/TypeScript/issues/27328#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmicrosoft%2FTypeScript%2Fissues%2F27328
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmicrosoft%2FTypeScript%2Fissues%2F27328
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=microsoft%2FTypeScript
Reloadhttps://github.com/microsoft/TypeScript/issues/27328
Reloadhttps://github.com/microsoft/TypeScript/issues/27328
Reloadhttps://github.com/microsoft/TypeScript/issues/27328
microsofthttps://github.com/microsoft
TypeScripthttps://github.com/microsoft/TypeScript
Codehttps://github.com/microsoft/TypeScript
Issues5k (5k)https://github.com/microsoft/TypeScript/issues
Pull requests312 (312)https://github.com/microsoft/TypeScript/pulls
Actionshttps://github.com/microsoft/TypeScript/actions
Projectshttps://github.com/microsoft/TypeScript/projects
Wikihttps://github.com/microsoft/TypeScript/wiki
Security and qualityhttps://github.com/microsoft/TypeScript/security
Insightshttps://github.com/microsoft/TypeScript/insights
https://github.com/microsoft/TypeScript
New issuehttps://github.com/login?return_to=https://github.com/microsoft/TypeScript/issues/27328
New issuehttps://github.com/login?return_to=https://github.com/microsoft/TypeScript/issues/27328
Constructor functions are not recognized as equivalent to classeshttps://github.com/microsoft/TypeScript/issues/27328#top
BugA bug in TypeScripthttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Bug%22
Domain: JSDocRelates to JSDoc parsing and type generationhttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Domain%3A%20JSDoc%22
checkJsRelates to checking JavaScript using TypeScripthttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22checkJs%22
Backloghttps://github.com/microsoft/TypeScript/milestone/29
https://github.com/joma74
joma74 (joma74)https://github.com/joma74
on Sep 24, 2018https://github.com/microsoft/TypeScript/issues/27328#issue-363337931
http://www.typescriptlang.org/play/#src=function%20clazz1c()%7B%0D%0A%09this.constructorOnly%20%3D%200%0D%0A%09this.constructorUnknown%20%3D%20undefined%0D%0A%7D%0D%0A%0D%0Aclazz1c.prototype.method%20%3D%20function()%20%7B%0D%0A%09this.constructorOnly%20%3D%203%0D%0A%09this.constructorUnknown%20%3D%20%22plunkbat%22%0D%0A%09%7D%0D%0A%0D%0Amodule.exports%3Dclazz1chttp://www.typescriptlang.org/play/#src=function%20clazz1c()%7B%0D%0A%09this.constructorOnly%20%3D%200%0D%0A%09this.constructorUnknown%20%3D%20undefined%0D%0A%7D%0D%0A%0D%0Aclazz1c.prototype.method%20%3D%20function()%20%7B%0D%0A%09this.constructorOnly%20%3D%203%0D%0A%09this.constructorUnknown%20%3D%20%22plunkbat%22%0D%0A%09%7D%0D%0A%0D%0Amodule.exports%3Dclazz1c
Working as IntendedThe behavior described is the intended behavior; this is not a bughttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Working%20as%20Intended%22
on Sep 25, 2018https://github.com/microsoft/TypeScript/issues/27328#event-1864506566
https://github.com/joma74
joma74 (joma74)https://github.com/joma74
on Sep 25, 2018https://github.com/microsoft/TypeScript/issues/27328#issuecomment-424272573
Andy (Andrewkraft) (@Andy-MS)https://github.com/Andy-MS
https://github.com/Microsoft/TypeScript/wiki/Type-Checking-JavaScript-Files#constructor-functions-are-equivalent-to-classeshttps://github.com/Microsoft/TypeScript/wiki/Type-Checking-JavaScript-Files#constructor-functions-are-equivalent-to-classes
https://github.com/joma74
joma74 (joma74)https://github.com/joma74
on Sep 28, 2018https://github.com/microsoft/TypeScript/issues/27328#issuecomment-425542404
#18171https://github.com/microsoft/TypeScript/issues/18171
https://github.com/joma74
joma74 (joma74)https://github.com/joma74
on Oct 2, 2018https://github.com/microsoft/TypeScript/issues/27328#issuecomment-426441992
Andy (Andrewkraft) (@Andy-MS)https://github.com/Andy-MS
https://github.com/joma74
joma74 (joma74)https://github.com/joma74
on Oct 4, 2018https://github.com/microsoft/TypeScript/issues/27328#issuecomment-427167233
#27550https://github.com/microsoft/TypeScript/issues/27550
Working as IntendedThe behavior described is the intended behavior; this is not a bughttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Working%20as%20Intended%22
on Oct 8, 2018https://github.com/microsoft/TypeScript/issues/27328#event-1890693096
BugA bug in TypeScripthttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Bug%22
on Oct 8, 2018https://github.com/microsoft/TypeScript/issues/27328#event-1890693201
Domain: JSDocRelates to JSDoc parsing and type generationhttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Domain%3A%20JSDoc%22
on Oct 8, 2018https://github.com/microsoft/TypeScript/issues/27328#event-1890693326
checkJsRelates to checking JavaScript using TypeScripthttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22checkJs%22
on Oct 8, 2018https://github.com/microsoft/TypeScript/issues/27328#event-1890693470
Nathan Shively-Sanders (sandersn)https://github.com/sandersn
on Oct 8, 2018https://github.com/microsoft/TypeScript/issues/27328#event-1890693562
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
TypeScript 3.3https://github.com/microsoft/TypeScript/milestone/79
on Oct 10, 2018https://github.com/microsoft/TypeScript/issues/27328#event-1896393126
Nathan Shively-Sanders (sandersn)https://github.com/sandersn
TypeScript 3.3https://github.com/microsoft/TypeScript/milestone/79
TypeScript 3.4.0https://github.com/microsoft/TypeScript/milestone/86
on Jan 16, 2019https://github.com/microsoft/TypeScript/issues/27328#event-2078861604
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
Nathan Shively-Sanders (sandersn)https://github.com/sandersn
on Mar 14, 2019https://github.com/microsoft/TypeScript/issues/27328#event-2202135924
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
TypeScript 3.4.0https://github.com/microsoft/TypeScript/milestone/86
Backloghttps://github.com/microsoft/TypeScript/milestone/29
on Mar 14, 2019https://github.com/microsoft/TypeScript/issues/27328#event-2202135975
https://github.com/sandersn
Nathan Shively-Sanders (sandersn)https://github.com/sandersn
on Aug 21, 2019https://github.com/microsoft/TypeScript/issues/27328#issuecomment-523525590
joma74 (@joma74)https://github.com/joma74
Nathan Shively-Sanders (sandersn)https://github.com/sandersn
completedhttps://github.com/microsoft/TypeScript/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
on Aug 21, 2019https://github.com/microsoft/TypeScript/issues/27328#event-2573635173
joma74 (joma74)https://github.com/joma74
on Aug 21, 2019https://github.com/microsoft/TypeScript/issues/27328#event-2574291010
chore(dep-mgmt): microsoft/TypeScript#27328 acceptance @nexthttps://github.com/joma74/ts-in-js-1/commit/587eec296f08d295d2a0be381f2330810b1a2a10
microsoft/TypeScript#27328https://github.com/microsoft/TypeScript/issues/27328
587eec2https://github.com/joma74/ts-in-js-1/commit/587eec296f08d295d2a0be381f2330810b1a2a10
chore(dep-mgmt): microsoft/TypeScript#27328 acceptance @nexthttps://github.com/joma74/ts-in-js-1/commit/b84a67cb3769cef518036682f3afa0da6ab65f5c
microsoft/TypeScript#27328https://github.com/microsoft/TypeScript/issues/27328
b84a67chttps://github.com/joma74/ts-in-js-1/commit/b84a67cb3769cef518036682f3afa0da6ab65f5c
https://github.com/joma74
joma74 (joma74)https://github.com/joma74
on Aug 21, 2019https://github.com/microsoft/TypeScript/issues/27328#issuecomment-523625053
Nathan Shively-Sanders (@sandersn)https://github.com/sandersn
https://github.com/joma74
joma74 (joma74)https://github.com/joma74
on Aug 21, 2019https://github.com/microsoft/TypeScript/issues/27328#issuecomment-523626515
Nathan Shively-Sanders (sandersn)https://github.com/sandersn
on Aug 21, 2019https://github.com/microsoft/TypeScript/issues/27328#event-2574474824
https://github.com/sandersn
Nathan Shively-Sanders (sandersn)https://github.com/sandersn
on Jul 27, 2020https://github.com/microsoft/TypeScript/issues/27328#issuecomment-664584030
Nathan Shively-Sanders (sandersn)https://github.com/sandersn
completedhttps://github.com/microsoft/TypeScript/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
on Jul 27, 2020https://github.com/microsoft/TypeScript/issues/27328#event-3591258823
microsofthttps://github.com/microsoft
on Oct 21, 2025https://github.com/microsoft/TypeScript/issues/27328#event-20415806815
Sign up for freehttps://github.com/signup?return_to=https://github.com/microsoft/TypeScript/issues/27328
Sign in to commenthttps://github.com/login?return_to=https://github.com/microsoft/TypeScript/issues/27328
BugA bug in TypeScripthttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Bug%22
Domain: JSDocRelates to JSDoc parsing and type generationhttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Domain%3A%20JSDoc%22
checkJsRelates to checking JavaScript using TypeScripthttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22checkJs%22
BacklogNo due datehttps://github.com/microsoft/TypeScript/milestone/29
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.