Skip to content
This repository was archived by the owner on Jan 19, 2019. It is now read-only.

Only warn about an unsupported TypeScript version once #347

Merged
merged 6 commits into from
Aug 9, 2017
Merged
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const ACTIVE_TYPESCRIPT_VERSION = ts.version;
const isRunningSupportedTypeScriptVersion = semver.satisfies(ACTIVE_TYPESCRIPT_VERSION, SUPPORTED_TYPESCRIPT_VERSIONS);

let extra;
let warnedAboutTSVersion = false;

/**
* Resets the extra config object
Expand Down Expand Up @@ -99,11 +100,14 @@ function parse(code, options) {
*/
if (typeof options.loggerFn === "function") {
extra.log = options.loggerFn;
} else if (options.loggerFn === false) {
/** */ // eslint-disable-line valid-jsdoc
Copy link
Member

@JamesHenry JamesHenry Aug 9, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bit odd 😄 Why not put the // eslint-disable-line valid-jsdoc on the line of the function you are disabling? Alternatively you could use Function.prototype as the value of the noop

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I don’t add the JSDoc comment, it errors at line 98 instead. I’ll switch to Function.prototype.

extra.log = () => {};
}

}

if (!isRunningSupportedTypeScriptVersion) {
if (!isRunningSupportedTypeScriptVersion && !warnedAboutTSVersion) {
const border = "=============";
const versionWarning = [
border,
Expand All @@ -115,6 +119,7 @@ function parse(code, options) {
border
];
extra.log(versionWarning.join("\n\n"));
warnedAboutTSVersion = true;
}

// Even if jsx option is set in typescript compiler, filename still has to
Expand Down