-
-
Notifications
You must be signed in to change notification settings - Fork 31.7k
process: add process.features.typescript
#54295
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -310,6 +310,29 @@ ObjectDefineProperty(process, 'features', { | |
} | ||
|
||
const { emitWarning, emitWarningSync } = require('internal/process/warning'); | ||
const { getOptionValue } = require('internal/options'); | ||
|
||
let kTypeStrippingMode = null; | ||
// This must be a getter, as getOptionValue does not work | ||
// before bootstrapping. | ||
ObjectDefineProperty(process.features, 'typescript', { | ||
avivkeller marked this conversation as resolved.
Show resolved
Hide resolved
avivkeller marked this conversation as resolved.
Show resolved
Hide resolved
avivkeller marked this conversation as resolved.
Show resolved
Hide resolved
|
||
__proto__: null, | ||
get() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This needs to emit experimental warning. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I disagree, we should not discourage feature detection, that'd just nudge folks into either disabling warnings and/or find another way for detecting typescript support. Also, I don't think this should be a getter, there's nothing dynamic about it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we don't emit experimental warning here, and mark this as experimental, how can we remove this API if the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Anything documented as experimental can be deleted at any time – and folks should write their code in a way that it still works whether I expect lots of folks to prefer not use an API that may emit a warning (because users don't like them), so they would have to find another way to detect "TS" support, so what's the point of adding this in the first place if we don't want folks to use it? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree with @aduh95 , if typescript is enabled, it will emit the warning regardless, if typescript is disabled, it returns false. Even if it does not emit the warning we can remove it. I dont see something that will be hard to remove since it returns a falsy value anyways. And having a warning in application that are not currently using ts feels like would impact adoption. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Got it. I'll remove the emitted warning when I get a chance. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please don't resolve a review that isn't addressed. @redyetidev. I recommend looking into this once again @marco-ippolito @aduh95. If you insist, I'll remove my block but this is an experimental feature that we should emit experimental warning for (according to documentation) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My apologies, I assumed this was resolved given the opposing opinions There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I insist, I’m -1 on landing this with a runtime warning. I’d recommend using stability 1 Experimental and not stability 1.0 nonsense if that’s where the point of contention lies. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I marked it with the same stability that type strip support is labeled under, but I can change it |
||
if (kTypeStrippingMode === null) { | ||
avivkeller marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if (getOptionValue('--experimental-transform-types')) { | ||
kTypeStrippingMode = 'transform'; | ||
} else if (getOptionValue('--experimental-strip-types')) { | ||
kTypeStrippingMode = 'strip'; | ||
} else { | ||
kTypeStrippingMode = false; | ||
} | ||
} | ||
return kTypeStrippingMode; | ||
}, | ||
configurable: true, | ||
enumerable: true, | ||
}); | ||
|
||
process.emitWarning = emitWarning; | ||
internalBinding('process_methods').setEmitWarningSync(emitWarningSync); | ||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.