René's URL Explorer Experiment


Title: Feature Request: Expose TS configuration and internals as Types · Issue #50196 · microsoft/TypeScript · GitHub

Open Graph Title: Feature Request: Expose TS configuration and internals as Types · Issue #50196 · microsoft/TypeScript

X Title: Feature Request: Expose TS configuration and internals as Types · Issue #50196 · microsoft/TypeScript

Description: Suggestion 🔍 Search Terms expose CompilerOptions types ✅ Viability Checklist My suggestion meets these guidelines: This wouldn't be a breaking change in existing TypeScript/JavaScript code This wouldn't change the runtime behavior of exi...

Open Graph Description: Suggestion 🔍 Search Terms expose CompilerOptions types ✅ Viability Checklist My suggestion meets these guidelines: This wouldn't be a breaking change in existing TypeScript/JavaScript code This wou...

X Description: Suggestion 🔍 Search Terms expose CompilerOptions types ✅ Viability Checklist My suggestion meets these guidelines: This wouldn't be a breaking change in existing TypeScript/JavaScript code This...

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

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Feature Request: Expose TS configuration and internals as Types","articleBody":"# Suggestion\r\n\r\n## 🔍 Search Terms\r\n\r\nexpose CompilerOptions types \r\n\r\n## ✅ Viability Checklist\r\n\r\n\u003c!--\r\n   Suggestions that don't meet all these criteria are very, very unlikely to be accepted.\r\n   We always recommend reviewing the TypeScript design goals before investing time writing\r\n   a proposal for ideas outside the scope of the project.\r\n-->\r\nMy suggestion meets these guidelines:\r\n\r\n* [x] This wouldn't be a breaking change in existing TypeScript/JavaScript code\r\n* [x] This wouldn't change the runtime behavior of existing JavaScript code\r\n* [x] This could be implemented without emitting different JS based on the types of the expressions\r\n* [x] This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, new syntax sugar for JS, etc.)\r\n* [x] This feature would agree with the rest of [TypeScript's Design Goals](https://github.com/Microsoft/TypeScript/wiki/TypeScript-Design-Goals).\r\n\r\n\r\n## ⭐ Suggestion\r\n\r\nI want to suggest that TypeScript would add some global namespace that contains information about the current running setup:\r\n\r\n* TS version (having some `AtLeast` type like I showcase in our \"hacked use cases\" below would be great too, but if we know the major and the minor we can also do that in userland)\r\n* active `compilerOptions` flags - it would be amazing to have some string union `TypeScript.CompilerOptions.ActiveFlags` where we could just do \r\n```ts\r\n'strictNullChecks' extends TypeScript.CompilerOptions.ActiveFlags ? SomeBehaviour : SomeLessSafeFallback\r\n```\r\n* the current `compilerOptions` in general - I don't know why someone would need access to `TypeScript.CompilerOptions.allowSyntheticDefaultImports` but it would feel like a waste not to expose that\r\n\r\n\r\n## 📃 Motivating Example\r\n\r\n```ts\r\ntype MessageFromTypeScript = AtLeast\u003c[TypeScript.Version.Major, TypeScript.Version.Minor], [4, 8]> extends true \r\n? \"it's the future\" \r\n: \"you live in the past\"\r\n\r\nclass MyRecord\u003cT>{\r\n  get(index: string): \r\n    'noUncheckedIndexedAccess' extends TypeScript.CompilerOptions.ActiveFlags \r\n    ? (T | undefined) \r\n    : T\r\n}\r\n```\r\n\r\n## 💻 Use Cases\r\n\r\nAs library authors, we currently have to apply quite a number of hacks to support as many versions of TypeScript and as many different user configurations as possible.\r\n\r\nSome example problems we are facing:\r\n\r\n1. Slight behavioral changes between TS versions. For example, #49307 forced us to change a `{}` to `ACR[T]` - but only in TS versions above 4.8. The fix breaks in older versions.\r\n2. Behavioral changes depending on `tsconfig.json` settings. Imagine a mapped type with functions.\r\n  The user specifies `someMethod(action: PayloadAction\u003cstring>): void` and we map that over to a `someMethod(arg: string): void`. \r\n  In the case the user specifies `someMethod(action: PayloadAction\u003cstring | undefined>): void`, we map it over to an optional argument in the form `someMethod(arg?: string): void`\r\n  Now assume the user has `strictNullChecks: false` in their tsconfig. Suddenly everything falls into the second case. \r\n3. A library might for example also behave differently if the user has `noUncheckedIndexedAccess: true` in their `tsconfig.json`\r\n\r\nThis leads to quite a few weird hacks in library types that might essentially break with every new release.\r\n\r\n1. Could be solved with a `typesVersion`, but honestly: if we can avoid having two complete sets of types, we want to avoid that. We had it for a while for pre-4.1 types and post-4.1 types and maintaining it was a pain. Right now, I've published https://github.com/phryneas/ts-version/ which uses a monstrous `package.json` with typesVersions just to export the current TS Major and Minor.  \r\nSo we solve our problem with an additional dependency and \r\n```ts\r\nimport('@phryneas/ts-version').TSVersion.AtLeast\u003c4, 8> extends true\r\n      ? ACR[T]\r\n      : {}\r\n```\r\nIn the past we used hacks like\r\n```ts\r\nexport type AtLeastTS35\u003cTrue, False> = [True, False][IsUnknown\u003cReturnType\u003c\u003cT>() => T>, 0, 1>]\r\n```\r\nfor that.\r\nFor a while we also had a subfolder with a `package.json` that would only use `typesVersions` on one import in that subfolder. At least we did not have to maintain two complete separate type definitions, but let's say it was not a great developer experience.\r\n2. We check for `strictNullChecks` with \r\n```ts\r\ntype WithStrictNullChecks\u003cTrue, False> = undefined extends boolean ? False : True;\r\n```\r\n3. We are not doing this yet but I'm sure we'd find a way to *somehow* detect `noUncheckedIndexedAccess` as well.\r\n\r\n\r\nAll that said: we have problems and we have solutions. But our solutions feel horrible and wrong. And also, having a package around with 120 different `typesVersions` entries just to detect the current TypeScript version can't really be good for performance.\r\n\r\nI hope you're going to give this at least some consideration :)","author":{"url":"https://github.com/phryneas","@type":"Person","name":"phryneas"},"datePublished":"2022-08-05T13:27:07Z","url":"https://github.com/microsoft/TypeScript/issues/50196"}

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:bcd1fb8b-58b7-5ff1-dc53-da09fab37b59
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idCAFA:1F65:11E3870:16B1A13:6B017737
html-safe-noncea186dc5d2b0edd366ddbc756487798a1b63e4bb9fb9f23ea889ffc548e924fd6
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDQUZBOjFGNjU6MTFFMzg3MDoxNkIxQTEzOjZCMDE3NzM3IiwidmlzaXRvcl9pZCI6IjY3NzkxNDI4NzI0NjY4MTQ3NzUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac4238cf584a6b71fdcf49784d4a04b80ff4bbfcc1eadcf7232124bd097a1f6da1
hovercard-subject-tagissue:1329940505
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/50196/issue_layout
twitter:imagehttps://opengraph.githubassets.com/8806b9a217234b378eaafb6b572fc8170fc7bb49fda56447a9d49bdb5d44fe92/microsoft/TypeScript/issues/50196
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/8806b9a217234b378eaafb6b572fc8170fc7bb49fda56447a9d49bdb5d44fe92/microsoft/TypeScript/issues/50196
og:image:altSuggestion 🔍 Search Terms expose CompilerOptions types ✅ Viability Checklist My suggestion meets these guidelines: This wouldn't be a breaking change in existing TypeScript/JavaScript code This wou...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamephryneas
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/50196#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmicrosoft%2FTypeScript%2Fissues%2F50196
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%2F50196
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/50196
Reloadhttps://github.com/microsoft/TypeScript/issues/50196
Reloadhttps://github.com/microsoft/TypeScript/issues/50196
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/50196
New issuehttps://github.com/login?return_to=https://github.com/microsoft/TypeScript/issues/50196
Feature Request: Expose TS configuration and internals as Typeshttps://github.com/microsoft/TypeScript/issues/50196#top
In DiscussionNot yet reached consensushttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22In%20Discussion%22
SuggestionAn idea for TypeScripthttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Suggestion%22
https://github.com/phryneas
Lenz Weber-Tronic (phryneas)https://github.com/phryneas
on Aug 5, 2022https://github.com/microsoft/TypeScript/issues/50196#issue-1329940505
TypeScript's Design Goalshttps://github.com/Microsoft/TypeScript/wiki/TypeScript-Design-Goals
Nightly bug(?) with infering function generic while being part of intersection #49307https://github.com/microsoft/TypeScript/issues/49307
https://github.com/phryneas/ts-version/https://github.com/phryneas/ts-version/
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
SuggestionAn idea for TypeScripthttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Suggestion%22
In DiscussionNot yet reached consensushttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22In%20Discussion%22
on Aug 5, 2022https://github.com/microsoft/TypeScript/issues/50196#event-7137125546
https://github.com/RyanCavanaugh
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
on Aug 5, 2022https://github.com/microsoft/TypeScript/issues/50196#issuecomment-1206637336
https://github.com/rbuckton
Ron Buckton (rbuckton)https://github.com/rbuckton
on Aug 5, 2022https://github.com/microsoft/TypeScript/issues/50196#issuecomment-1206719612
https://github.com/phryneas
Lenz Weber-Tronic (phryneas)https://github.com/phryneas
on Aug 5, 2022https://github.com/microsoft/TypeScript/issues/50196#issuecomment-1206839312
https://github.com/phryneas/ts-version/blob/e3517aac4011d1649cc2782628659653ec60b30b/index.d.ts#L34-L42https://github.com/phryneas/ts-version/blob/e3517aac4011d1649cc2782628659653ec60b30b/index.d.ts#L34-L42
https://github.com/phryneas
Lenz Weber-Tronic (phryneas)https://github.com/phryneas
on Aug 5, 2022https://github.com/microsoft/TypeScript/issues/50196#issuecomment-1206843991
https://github.com/MartinJohns
Martin Johns (MartinJohns)https://github.com/MartinJohns
on Aug 6, 2022https://github.com/microsoft/TypeScript/issues/50196#issuecomment-1207199898
https://github.com/markerikson
Mark Erikson (markerikson)https://github.com/markerikson
on Nov 3, 2022https://github.com/microsoft/TypeScript/issues/50196#issuecomment-1301609232
#50831 (comment)https://github.com/microsoft/TypeScript/pull/50831#issuecomment-1253830522
https://github.com/Andarist
Mateusz Burzyński (Andarist)https://github.com/Andarist
on Nov 3, 2022https://github.com/microsoft/TypeScript/issues/50196#issuecomment-1301762094
Mark Erikson (@markerikson)https://github.com/markerikson
@phryneas/ts-versionhttps://github.com/phryneas/ts-version
https://github.com/phryneas
Lenz Weber-Tronic (phryneas)https://github.com/phryneas
on Nov 3, 2022https://github.com/microsoft/TypeScript/issues/50196#issuecomment-1301762683
https://github.com/phryneas
Lenz Weber-Tronic (phryneas)https://github.com/phryneas
on Nov 3, 2022https://github.com/microsoft/TypeScript/issues/50196#issuecomment-1301765633
https://github.com/EskiMojo14
Ben Durrant (EskiMojo14)https://github.com/EskiMojo14
on May 8, 2023https://github.com/microsoft/TypeScript/issues/50196#issuecomment-1538374039
uncheckedindexedhttps://www.npmjs.com/package/uncheckedindexed
Sign up for freehttps://github.com/signup?return_to=https://github.com/microsoft/TypeScript/issues/50196
Sign in to commenthttps://github.com/login?return_to=https://github.com/microsoft/TypeScript/issues/50196
In DiscussionNot yet reached consensushttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22In%20Discussion%22
SuggestionAn idea for TypeScripthttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Suggestion%22
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.