René's URL Explorer Experiment


Title: Proposal: Granular Targeting · Issue #4692 · microsoft/TypeScript · GitHub

Open Graph Title: Proposal: Granular Targeting · Issue #4692 · microsoft/TypeScript

X Title: Proposal: Granular Targeting · Issue #4692 · microsoft/TypeScript

Description: This proposal is based on a working implementation at: https://github.com/yortus/TypeScript/tree/granular-targeting To try it out, clone it or install it with npm install yortus-typescript Problem Scenario The TypeScript compiler accepts...

Open Graph Description: This proposal is based on a working implementation at: https://github.com/yortus/TypeScript/tree/granular-targeting To try it out, clone it or install it with npm install yortus-typescript Problem ...

X Description: This proposal is based on a working implementation at: https://github.com/yortus/TypeScript/tree/granular-targeting To try it out, clone it or install it with npm install yortus-typescript Problem ...

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

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Proposal: Granular Targeting","articleBody":"This proposal is based on a working implementation at:\nhttps://github.com/yortus/TypeScript/tree/granular-targeting\nTo try it out, clone it or install it with `npm install yortus-typescript`\n## Problem Scenario\n\nThe TypeScript compiler accepts a single `target` option of either `ES3`, `ES5` or `ES6`. However, most realistic target environments support a mixture or ES5 and ES6, and even ES7, often known in advance (e.g. when targeting Node.js, and/or using polyfills).\n\nUsing TypeScript with target environments with mixed ES5/5/7 support presents some challenges, many of which have been discussed in other issues. E.g.:\n- (#4389) Support compile targets between ES5 and ES6\n- (#4168) Normalize our lib files by compiler settings\n- (#3215) New APIs added to lib.d.ts may break client codes. Allow duplicated members in interfaces? Make lib.d.ts overridable?\n- (#3005) Using ES6 type default library when targetting ES5 output\n- (#2695) for-of does not work with DOM collections when target is ES6\n- (somewhat related: (#2481) Create DOM-Level specific dom-version.d.ts)\n\nIn summary:\n- The default lib either includes all ES6 types and properties, or none of them.\n- Specifying `--noLib` and/or manually maintaining `lib.b.ts` files brings other problems:\n  - separate core typings are a burden to maintain.\n  - problems of missing symbols and clashing symbols.\n  - burden of manually tracking fixes and additions made in the default libs.\n- Targeting ES5 as the 'lowest common denominator' means some language features known to be supported cannot be used (eg generators in Node.js).\n- Targeting ES6 (e.g. to take advantage of Node.js' support for many ES6 features) leads to further complications:\n  - \u003cdel\u003eCommonJS modules won't compile, even though that's the only module system Node supports.\u003c/del\u003e (fixed by #4811)\n  - The compiler emits ES6 even for features that are known _not_ to be supported, which would fail at runtime.\n  - Adding babel.js to the build pipeline adds complexity.\n## Workarounds\n#### To achieve mixed ES5/ES6 core typings:\n- specify `--target ES5` and selectively add ES6 typings in separately maintained files (eg from DefinitelyTyped).\n- specify `--target ES6` and be careful to avoid referencing unsupported ES6 features (the compiler won't issue any errors).\n- specify `--noLib` and manually maintain custom core typings in your own project.\n#### To use ES6 features supported by the target platform\n- specify `--target ES5` and (a) accept that things will be down-level emitted, and (b) don't use features with no down-level emit yet (ie generators).\n- specify `--target ES6` and (a) \u003cdel\u003econvert everything from CommonJS to ES6 modules\u003c/del\u003e (fixed by #4811), (b) add babel.js to the build pipeline, and (c) configure babel.js to do either pass-through or down-level emit on a feature-by-feature basis.\n## Proposed Solution\n\nThis proposal consists of two parts:\n\n\u003cdel\u003e1. Support for conditional compilation using `#if` and `#endif` directives, so that a single default lib can offer fine-grained typings tailored to a mixed ES3/5/6/7 target environment.\u003c/del\u003e\n\n\n\u003cdel\u003eThe conditional compilation part is detailed in a separate proposal (#4691) with its own [working implementation](https://github.com/yortus/TypeScript/tree/preprocessor-directives).\u003c/del\u003e\n\n\n**1. A mechanism allowing the default lib to offer fine-grained typings tailored to a mixed ES3/5/6/7 target environment.**\n\nThis is really an internal compiler detail, so the mechanism is open to debate. It just has to match the granularity supported by the new compiler options below.\n\nThe [working implementation](https://github.com/yortus/TypeScript/tree/granular-targeting) uses `#if...#endif` conditional compilation proposed in #4691. But this is overkill for this use case and [seems unlikely](https://github.com/Microsoft/TypeScript/issues/4691#issuecomment-138678473) to be considered.\n\nSeveral other mechanisms have been discussed (summarized [here](https://github.com/Microsoft/TypeScript/issues/4692#issuecomment-138750104)).\n\n**2. Support for additional compiler options allowing the target environment to be described on a feature-by-feature basis.**\n\nUnder this proposal, the `target` option remains, but is now interpreted as the 'baseline' target, determining which features the target supports by default. For instance, ES6 symbols and generators are supported by default if `target` is set to `ES6` or higher.\n\nThe additional compiler options have the form `targetHasXYZ`, where `XYZ` designates a feature. These options are used to override the target for a particular language feature. They instruct the compiler that the target environment explicitly does or does not support a particular feature, regardless of what the `target` option otherwise imples.\n\nThe [working implementation](https://github.com/yortus/TypeScript/tree/granular-targeting) currently supports the following additional compiler options (all boolean):\n- `targetHasArrowFunctions`: specify whether the target supports ES6 `() =\u003e {...}` syntax\n- `targetHasBlockScoping`: specify whether the target supports ES6 `let` and `const`\n- `targetHasForOf`: specify whether the target supports ES6 `for..of` syntax\n- `targetHasGenerators`: specify whether the target supports ES6 generators\n- `targetHasIterables`: specify whether the target supports ES6 iterables and iterators\n- `targetHasModules`: specify whether the target supports ES6 modules\n- `targetHasPromises`: specify whether the target supports ES6 promises\n- `targetHasSymbols`: specify whether the target supports ES6 symbols\n\nThese options work both on the command line and in `tsconfig.json` files.\n## Example `tsconfig.json` Files and their Behaviour\n#### A.\n\n``` json\n{\n    \"target\": \"es6\",\n    \"targetHasModules\": false,\n    \"targetHasBlockScoping\": false,\n    \"module\": \"commonjs\"\n}\n```\n\nEmits ES6 JavaScript, except with CommonJS module syntax, and with `let`/`const` down-leveled to `var`. This might match a Node.js environment.\n#### B.\n\n``` json\n{\n    \"target\": \"es5\",\n    \"targetHasSymbols\": true\n}\n```\n\nEmits ES5 JavaScript, except with Symbol references emitted as-is, and with full type support for well-known symbols from the default lib.\n#### C.\n\n``` json\n{\n    \"target\": \"es5\",\n    \"targetHasPromises\": true\n}\n```\n\nEmits ES5 JavaScript, except with full type support for ES6 promises from the default lib. This would work in an ES5 environment with a native or polyfilled `Promise` object.\n## Backward Compatibility, Design Impact, Performance, etc\n- There is no impact on existing TypeScript projects. The additional options and preprocessor directives only modify the compiler's behaviour if they are explicitly used.\n- The preprocessor directives `#if` and `#endif` add new language syntax. No existing language features are affected.\n- There is negligable impact on compiler performance.\n- Only one default lib is needed (`lib.es6.d.ts`). It contains many conditionally compiled sections (ie with `#if` and `#endif`)\n## Remaining Work and Questions\n- Support compiler options for more target features, e.g.:\n  - template strings\n  - classes\n  - `Map`/`Set`/`WeakMap`/`WeakSet`\n  - binary and octal literals\n  - destructuring\n  - default, rest, and optional parameters\n- How granular could/should targets be? Feature support is naturally hierarchical. E.g. block scoping may be separated into (a) `let`, (b) `const` and (c) block-level function declaration. This is true of most features and their realistic implementations (the [Kangax ES6 compatibility table](https://kangax.github.io/compat-table/es6/) has a three-level hierarchy down the left side).\n","author":{"url":"https://github.com/yortus","@type":"Person","name":"yortus"},"datePublished":"2015-09-08T15:54:37.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":51},"url":"https://github.com/4692/TypeScript/issues/4692"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:443e4d49-1d0c-3cb2-7cef-402c6b191e73
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id9C3A:2846D4:991C5B:D332CC:6A624A05
html-safe-nonce7b344b2a349436110699c9bd552b75f475fcd9f823e5332228cd11ac4b47a86c
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5QzNBOjI4NDZENDo5OTFDNUI6RDMzMkNDOjZBNjI0QTA1IiwidmlzaXRvcl9pZCI6Ijc1ODk0Mjg5MDI4NDg3NzY3MDkiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac3cff4f0a0c4e8528a7d02bd60a9cdfa920f9bf968db11e828c82f1f4db5e9ab5
hovercard-subject-tagissue:105411159
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/4692/issue_layout
twitter:imagehttps://opengraph.githubassets.com/7d45f165aa8c0fb395cfb1cc4c144f9b4ed7c23c8e9e3ee38439275bb2b06ec6/microsoft/TypeScript/issues/4692
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/7d45f165aa8c0fb395cfb1cc4c144f9b4ed7c23c8e9e3ee38439275bb2b06ec6/microsoft/TypeScript/issues/4692
og:image:altThis proposal is based on a working implementation at: https://github.com/yortus/TypeScript/tree/granular-targeting To try it out, clone it or install it with npm install yortus-typescript Problem ...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameyortus
hostnamegithub.com
expected-hostnamegithub.com
None5d6ba65d73ecc4e3394fe318d2b2f98e6f8eed4878b5421b938e20d30bde267b
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
release2dadc56fd5989b76a8ae7304e3aa56d0b485e5dc
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/microsoft/TypeScript/issues/4692#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmicrosoft%2FTypeScript%2Fissues%2F4692
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
Code QualityEnforce quality at mergehttps://github.com/features/code-quality
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
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
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/open-source/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/open-source/accelerator
GitHub Starshttps://stars.github.com
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://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
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmicrosoft%2FTypeScript%2Fissues%2F4692
Sign up https://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/4692
Reloadhttps://github.com/microsoft/TypeScript/issues/4692
Reloadhttps://github.com/microsoft/TypeScript/issues/4692
Please reload this pagehttps://github.com/microsoft/TypeScript/issues/4692
microsoft https://github.com/microsoft
TypeScripthttps://github.com/microsoft/TypeScript
Notifications https://github.com/login?return_to=%2Fmicrosoft%2FTypeScript
Fork 13.6k https://github.com/login?return_to=%2Fmicrosoft%2FTypeScript
Star 110k https://github.com/login?return_to=%2Fmicrosoft%2FTypeScript
Code https://github.com/microsoft/TypeScript
Issues 5k+ https://github.com/microsoft/TypeScript/issues
Pull requests 21 https://github.com/microsoft/TypeScript/pulls
Actions https://github.com/microsoft/TypeScript/actions
Projects https://github.com/microsoft/TypeScript/projects
Models https://github.com/microsoft/TypeScript/models
Wiki https://github.com/microsoft/TypeScript/wiki
Security and quality 0 https://github.com/microsoft/TypeScript/security
Insights https://github.com/microsoft/TypeScript/pulse
Code https://github.com/microsoft/TypeScript
Issues https://github.com/microsoft/TypeScript/issues
Pull requests https://github.com/microsoft/TypeScript/pulls
Actions https://github.com/microsoft/TypeScript/actions
Projects https://github.com/microsoft/TypeScript/projects
Models https://github.com/microsoft/TypeScript/models
Wiki https://github.com/microsoft/TypeScript/wiki
Security and quality https://github.com/microsoft/TypeScript/security
Insights https://github.com/microsoft/TypeScript/pulse
Proposal: Granular Targetinghttps://github.com/microsoft/TypeScript/issues/4692#top
SuggestionAn idea for TypeScripthttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Suggestion%22
https://github.com/yortus
yortushttps://github.com/yortus
on Sep 8, 2015https://github.com/microsoft/TypeScript/issues/4692#issue-105411159
https://github.com/yortus/TypeScript/tree/granular-targetinghttps://github.com/yortus/TypeScript/tree/granular-targeting
Support compile targets between ES5 and ES6 #4389https://github.com/microsoft/TypeScript/issues/4389
Normalize our lib files by compiler settings #4168https://github.com/microsoft/TypeScript/issues/4168
New APIs added to lib.d.ts may break client codes. Allow duplicated members in interfaces? Make lib.d.ts overridable? #3215https://github.com/microsoft/TypeScript/issues/3215
Using ES6 type default library when targetting ES5 output #3005https://github.com/microsoft/TypeScript/issues/3005
for-of does not work with some DOM collections when target is ES6 #2695https://github.com/microsoft/TypeScript/issues/2695
Create DOM-Level specific dom-version.d.ts #2481https://github.com/microsoft/TypeScript/issues/2481
Support modules when targeting ES6 and an ES6 ModuleKind #4811https://github.com/microsoft/TypeScript/pull/4811
Support modules when targeting ES6 and an ES6 ModuleKind #4811https://github.com/microsoft/TypeScript/pull/4811
#4691https://github.com/microsoft/TypeScript/issues/4691
working implementationhttps://github.com/yortus/TypeScript/tree/preprocessor-directives
working implementationhttps://github.com/yortus/TypeScript/tree/granular-targeting
#4691https://github.com/microsoft/TypeScript/issues/4691
seems unlikelyhttps://github.com/Microsoft/TypeScript/issues/4691#issuecomment-138678473
herehttps://github.com/Microsoft/TypeScript/issues/4692#issuecomment-138750104
working implementationhttps://github.com/yortus/TypeScript/tree/granular-targeting
Kangax ES6 compatibility tablehttps://kangax.github.io/compat-table/es6/
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.