Enable esModuleInterop in TypeScript configuration

This commit is contained in:
Rafael Oleza 2020-07-08 10:41:20 +02:00
parent eee3cf8268
commit a3f21ac29b
No known key found for this signature in database
GPG key ID: 559647D09ED485D1
73 changed files with 115 additions and 102 deletions

View file

@ -1,4 +1,8 @@
import * as mri from 'mri'
import mri, {
DictionaryObject,
Options as MriOptions,
ArrayOrString,
} from 'mri'
import chalk from 'chalk'
import { dasherizeOption, CommandError } from './util'
@ -45,10 +49,10 @@ function logError(err: CommandError) {
console.log() // nice blank line before the command prompt
interface IMRIOpts extends mri.Options {
alias: mri.DictionaryObject<mri.ArrayOrString>
interface IMRIOpts extends MriOptions {
alias: DictionaryObject<ArrayOrString>
boolean: Array<string>
default: mri.DictionaryObject
default: DictionaryObject
string: Array<string>
}

View file

@ -2,7 +2,7 @@ import * as Path from 'path'
import { ChildProcess } from 'child_process'
import * as FSE from 'fs-extra'
import { GitError } from 'dugite'
import * as byline from 'byline'
import byline from 'byline'
import { Repository } from '../../models/repository'
import {

View file

@ -1,5 +1,5 @@
import * as Path from 'path'
import fileUrl = require('file-url')
import fileUrl from 'file-url'
/**
* Resolve and encode the path information into a URL.

View file

@ -1,7 +1,7 @@
import { ChildProcess } from 'child_process'
import * as Fs from 'fs'
import * as Path from 'path'
import * as byline from 'byline'
import byline from 'byline'
import { GitProgressParser, IGitProgress, IGitOutput } from './git'
import { IGitExecutionOptions } from '../git/core'

View file

@ -1,4 +1,4 @@
import * as moment from 'moment'
import moment from 'moment'
import {
ReleaseMetadata,

View file

@ -1,4 +1,4 @@
import * as Deque from 'double-ended-queue'
import Deque from 'double-ended-queue'
import {
FileEntry,

View file

@ -228,7 +228,7 @@ import {
import { BranchPruner } from './helpers/branch-pruner'
import { enableUpdateRemoteUrl } from '../feature-flag'
import { Banner, BannerType } from '../../models/banner'
import * as moment from 'moment'
import moment from 'moment'
import { isDarkModeEnabled } from '../../ui/lib/dark-theme'
import { ComputedAction } from '../../models/computed-action'
import {

View file

@ -12,7 +12,7 @@ import {
} from '../../git'
import { fatalError } from '../../fatal-error'
import { RepositoryStateCache } from '../repository-state-cache'
import * as moment from 'moment'
import moment from 'moment'
/** Check if a repo needs to be pruned at least every 4 hours */
const BackgroundPruneMinimumInterval = 1000 * 60 * 60 * 4

View file

@ -8,7 +8,7 @@ import { ILaunchStats } from '../lib/stats'
import { menuFromElectronMenu } from '../models/app-menu'
import { now } from './now'
import * as path from 'path'
import * as windowStateKeeper from 'electron-window-state'
import windowStateKeeper from 'electron-window-state'
export class AppWindow {
private window: Electron.BrowserWindow

View file

@ -12,7 +12,7 @@ import {
} from './app'
import { GitError, isAuthFailureError } from '../lib/git/core'
import { Popup, PopupType } from '../models/popup'
import { CSSTransitionGroup } from 'react-transition-group'
import CSSTransitionGroup from 'react-transition-group/CSSTransitionGroup'
import { OkCancelButtonGroup } from './dialog/ok-cancel-button-group'
import { ErrorWithMetadata } from '../lib/error-with-metadata'
import { RetryActionType, RetryAction } from '../models/retry-actions'

View file

@ -1,5 +1,5 @@
import * as React from 'react'
import * as classNames from 'classnames'
import classNames from 'classnames'
import { Octicon, OcticonSymbol } from '../octicons'
import { MenuItem } from '../../models/app-menu'

View file

@ -1,5 +1,5 @@
import * as React from 'react'
import * as classNames from 'classnames'
import classNames from 'classnames'
import { List, ClickSource, SelectionSource } from '../lib/list'
import {

View file

@ -1,6 +1,6 @@
import * as React from 'react'
import { ipcRenderer, remote } from 'electron'
import { CSSTransitionGroup } from 'react-transition-group'
import CSSTransitionGroup from 'react-transition-group/CSSTransitionGroup'
import {
IAppState,

View file

@ -7,7 +7,7 @@ import {
} from '../lib/list'
import { IAutocompletionProvider } from './index'
import { fatalError } from '../../lib/fatal-error'
import * as classNames from 'classnames'
import classNames from 'classnames'
interface IRange {
readonly start: number

View file

@ -1,5 +1,5 @@
import * as React from 'react'
import * as moment from 'moment'
import moment from 'moment'
import { IMatches } from '../../lib/fuzzy-find'

View file

@ -2,7 +2,7 @@ import * as React from 'react'
import { Octicon, OcticonSymbol } from '../octicons'
import { APIRefState, IAPIRefStatus } from '../../lib/api'
import { assertNever } from '../../lib/fatal-error'
import * as classNames from 'classnames'
import classNames from 'classnames'
import { getRefStatusSummary } from './pull-request-status'
import { GitHubRepository } from '../../models/github-repository'
import { IDisposable } from 'event-kit'

View file

@ -1,6 +1,6 @@
import * as React from 'react'
import * as moment from 'moment'
import * as classNames from 'classnames'
import moment from 'moment'
import classNames from 'classnames'
import { Octicon, OcticonSymbol } from '../octicons'
import { CIStatus } from './ci-status'
import { HighlightText } from '../lib/highlight-text'

View file

@ -1,5 +1,5 @@
import * as React from 'react'
import * as moment from 'moment'
import moment from 'moment'
import {
FilterList,
IFilterListGroup,

View file

@ -36,7 +36,7 @@ import { RebaseConflictState, ConflictState } from '../../lib/app-state'
import { ContinueRebase } from './continue-rebase'
import { Octicon, OcticonSymbol } from '../octicons'
import { IStashEntry } from '../../models/stash-entry'
import * as classNames from 'classnames'
import classNames from 'classnames'
import { hasWritePermission } from '../../models/github-repository'
import { hasConflictedFiles } from '../../lib/status'

View file

@ -1,5 +1,5 @@
import * as React from 'react'
import * as classNames from 'classnames'
import classNames from 'classnames'
import {
AutocompletingTextArea,
AutocompletingInput,

View file

@ -28,7 +28,7 @@ import {
} from '../autocompletion'
import { ClickSource } from '../lib/list'
import { WorkingDirectoryFileChange } from '../../models/status'
import { CSSTransitionGroup } from 'react-transition-group'
import CSSTransitionGroup from 'react-transition-group/CSSTransitionGroup'
import { openFile } from '../lib/open-file'
import { Account } from '../../models/account'
import { PopupType } from '../../models/popup'

View file

@ -1,5 +1,5 @@
import * as React from 'react'
import * as classNames from 'classnames'
import classNames from 'classnames'
interface IDialogContentProps {
/**

View file

@ -1,5 +1,5 @@
import * as React from 'react'
import * as classNames from 'classnames'
import classNames from 'classnames'
import { DialogHeader } from './header'
import { createUniqueId, releaseUniqueId } from '../lib/id-pool'

View file

@ -1,5 +1,5 @@
import * as React from 'react'
import * as classNames from 'classnames'
import classNames from 'classnames'
import { Button } from '../lib/button'
interface IOkCancelButtonGroupProps {

View file

@ -1,12 +1,5 @@
import * as React from 'react'
import * as CodeMirror from 'codemirror'
// Required for us to be able to customize the foreground color of selected text
import 'codemirror/addon/selection/mark-selection'
// Autocompletion plugin
import 'codemirror/addon/hint/show-hint'
import {
import CodeMirror, {
Doc,
EditorChangeLinkedList,
Editor,
@ -14,6 +7,12 @@ import {
LineHandle,
} from 'codemirror'
// Required for us to be able to customize the foreground color of selected text
import 'codemirror/addon/selection/mark-selection'
// Autocompletion plugin
import 'codemirror/addon/hint/show-hint'
if (__DARWIN__) {
// This has to be required to support the `simple` scrollbar style.
require('codemirror/addon/scroll/simplescrollbars')
@ -76,7 +75,7 @@ interface ICodeMirrorHostProps {
* given editor by accessing undocumented APIs. This is likely
* to break in the future.
*/
function cancelActiveSelection(cm: CodeMirror.Editor) {
function cancelActiveSelection(cm: Editor) {
if (cm.state && cm.state.selectingText instanceof Function) {
try {
// Simulate a mouseup event which will cause CodeMirror

View file

@ -3,7 +3,7 @@ import { ImageContainer } from './image-container'
import { ICommonImageDiffProperties } from './modified-image-diff'
import { ISize } from './sizing'
import { formatBytes, Sign } from '../../lib/bytes'
import * as classNames from 'classnames'
import classNames from 'classnames'
interface ITwoUpProps extends ICommonImageDiffProperties {
readonly previousImageSize: ISize | null

View file

@ -1,5 +1,5 @@
import * as React from 'react'
import * as classNames from 'classnames'
import classNames from 'classnames'
import { Repository } from '../../models/repository'

View file

@ -1,5 +1,5 @@
import * as React from 'react'
import * as classNames from 'classnames'
import classNames from 'classnames'
import { FileChange } from '../../models/status'
import { Octicon, OcticonSymbol } from '../octicons'

View file

@ -1,5 +1,5 @@
import * as React from 'react'
import { CSSTransitionGroup } from 'react-transition-group'
import CSSTransitionGroup from 'react-transition-group/CSSTransitionGroup'
import { IGitHubUser } from '../../lib/databases'
import { Commit } from '../../models/commit'

View file

@ -4,7 +4,7 @@ import * as React from 'react'
import * as ReactDOM from 'react-dom'
import * as Path from 'path'
import * as moment from 'moment'
import moment from 'moment'
import { ipcRenderer, remote } from 'electron'

View file

@ -1,5 +1,5 @@
import * as React from 'react'
import * as classNames from 'classnames'
import classNames from 'classnames'
interface IAccessTextProps {
/**

View file

@ -1,5 +1,5 @@
import * as React from 'react'
import * as classNames from 'classnames'
import classNames from 'classnames'
import { ComputedAction } from '../../models/computed-action'
import { assertNever } from '../../lib/fatal-error'

View file

@ -1,9 +1,14 @@
import * as React from 'react'
import * as CodeMirror from 'codemirror'
import CodeMirror, {
Editor,
EditorConfiguration,
Doc,
Position,
TextMarkerOptions,
} from 'codemirror'
import * as URL from 'url'
import * as classNames from 'classnames'
import classNames from 'classnames'
import { UserAutocompletionProvider, IUserHit } from '../autocompletion'
import { Editor, Doc, Position } from 'codemirror'
import { getDotComAPIEndpoint } from '../../lib/api'
import { compare } from '../../lib/compare'
import { arrayEquals } from '../../lib/equality'
@ -177,7 +182,7 @@ function scanUntil(
function appendTextMarker(
cm: Editor,
text: string,
options: CodeMirror.TextMarkerOptions
options: TextMarkerOptions
): ActualTextMarker {
const doc = cm.getDoc()
const from = doc.posFromIndex(Infinity)
@ -206,7 +211,7 @@ function orderByPosition(x: ActualTextMarker, y: ActualTextMarker) {
// The types for CodeMirror.TextMarker is all wrong, this is what it
// actually looks like
// eslint-disable-next-line @typescript-eslint/naming-convention
interface ActualTextMarker extends CodeMirror.TextMarkerOptions {
interface ActualTextMarker extends TextMarkerOptions {
/** Remove the mark. */
clear(): void
@ -696,7 +701,7 @@ export class AuthorInput extends React.Component<IAuthorInputProps, {}> {
}
private initializeCodeMirror(host: HTMLDivElement) {
const CodeMirrorOptions: CodeMirror.EditorConfiguration & {
const CodeMirrorOptions: EditorConfiguration & {
hintOptions: any
} = {
mode: null,

View file

@ -1,5 +1,5 @@
import * as React from 'react'
import * as classNames from 'classnames'
import classNames from 'classnames'
import { Avatar } from './avatar'
import { IAvatarUser } from '../../models/avatar'

View file

@ -1,5 +1,5 @@
import * as React from 'react'
import * as classNames from 'classnames'
import classNames from 'classnames'
export interface IButtonProps {
/**

View file

@ -1,5 +1,5 @@
import * as React from 'react'
import * as classNames from 'classnames'
import classNames from 'classnames'
interface IErrorsProps {
/** The class name for the internal element. */

View file

@ -1,7 +1,7 @@
import * as React from 'react'
import { Octicon, OcticonSymbol } from '../octicons'
import { TextBox, ITextBoxProps } from './text-box'
import * as classNames from 'classnames'
import classNames from 'classnames'
interface IFancyTextBoxProps extends ITextBoxProps {
/** Icon to render */

View file

@ -1,5 +1,5 @@
import * as React from 'react'
import * as classnames from 'classnames'
import classnames from 'classnames'
import {
List,

View file

@ -1,5 +1,5 @@
import * as React from 'react'
import * as classNames from 'classnames'
import classNames from 'classnames'
interface IFocusContainerProps {
readonly className?: string

View file

@ -1,5 +1,5 @@
import * as React from 'react'
import * as classNames from 'classnames'
import classNames from 'classnames'
interface IFormProps {
/** The class name for the form. */

View file

@ -1,6 +1,6 @@
import * as React from 'react'
import { shell } from '../../lib/app-shell'
import * as classNames from 'classnames'
import classNames from 'classnames'
interface ILinkButtonProps {
/** A URI to open on click. */

View file

@ -1,5 +1,5 @@
import * as React from 'react'
import * as classNames from 'classnames'
import classNames from 'classnames'
interface IListRowProps {
/** the total number of row in this list */

View file

@ -1,5 +1,5 @@
import * as React from 'react'
import * as classNames from 'classnames'
import classNames from 'classnames'
interface IRowProps {
/** The class name for the internal element. */

View file

@ -1,5 +1,5 @@
import * as React from 'react'
import * as classNames from 'classnames'
import classNames from 'classnames'
import { showContextualMenu } from '../main-process-proxy'
interface ITextAreaProps {

View file

@ -1,5 +1,5 @@
import * as React from 'react'
import * as classNames from 'classnames'
import classNames from 'classnames'
import { createUniqueId, releaseUniqueId } from './id-pool'
import { LinkButton } from './link-button'
import { showContextualMenu } from '../main-process-proxy'

View file

@ -1,5 +1,5 @@
import * as React from 'react'
import * as classNames from 'classnames'
import classNames from 'classnames'
interface IToggleButtonProps {
/**

View file

@ -1,6 +1,6 @@
import * as React from 'react'
import { OcticonSymbol } from './octicons.generated'
import * as classNames from 'classnames'
import classNames from 'classnames'
import { createUniqueId, releaseUniqueId } from '../lib/id-pool'
interface IOcticonProps {

View file

@ -1,5 +1,5 @@
import * as React from 'react'
import * as moment from 'moment'
import moment from 'moment'
interface IRelativeTimeProps {
/**

View file

@ -1,6 +1,6 @@
import * as React from 'react'
import * as ReactCSSTransitionReplace from 'react-css-transition-replace'
import ReactCSSTransitionReplace from 'react-css-transition-replace'
interface ISuggestedActionGroup {
/**

View file

@ -1,5 +1,5 @@
import * as React from 'react'
import * as classNames from 'classnames'
import classNames from 'classnames'
import { Button } from '../lib/button'
interface ISuggestedActionProps {

View file

@ -1,5 +1,5 @@
import * as React from 'react'
import * as classNames from 'classnames'
import classNames from 'classnames'
/** The tab bar type. */
export enum TabBarType {

View file

@ -9,7 +9,7 @@ import { BranchesContainer, PullRequestBadge } from '../branches'
import { assertNever } from '../../lib/fatal-error'
import { BranchesTab } from '../../models/branches-tab'
import { PullRequest } from '../../models/pull-request'
import * as classNames from 'classnames'
import classNames from 'classnames'
import { UncommittedChangesStrategy } from '../../models/uncommitted-changes-strategy'
interface IBranchDropdownProps {

View file

@ -1,6 +1,6 @@
import * as React from 'react'
import { Octicon, OcticonSymbol } from '../octicons'
import * as classNames from 'classnames'
import classNames from 'classnames'
import { assertNever } from '../../lib/fatal-error'
import { Button } from '../lib/button'
import { clamp } from '../../lib/clamp'

View file

@ -3,7 +3,7 @@ import { Octicon, OcticonSymbol } from '../octicons'
import { assertNever } from '../../lib/fatal-error'
import { ToolbarButton, ToolbarButtonStyle } from './button'
import { rectEquals } from '../lib/rect'
import * as classNames from 'classnames'
import classNames from 'classnames'
export type DropdownState = 'open' | 'closed'

View file

@ -11,7 +11,7 @@ import { Octicon, OcticonSymbol } from '../octicons'
import { RelativeTime } from '../relative-time'
import { ToolbarButton, ToolbarButtonStyle } from './button'
import * as classNames from 'classnames'
import classNames from 'classnames'
interface IPushPullButtonProps {
/**

View file

@ -1,5 +1,5 @@
import * as React from 'react'
import * as classNames from 'classnames'
import classNames from 'classnames'
interface IUiViewProps extends React.HTMLProps<HTMLDivElement> {}

View file

@ -1,5 +1,5 @@
import * as React from 'react'
import * as classNames from 'classnames'
import classNames from 'classnames'
import { Dispatcher } from '../dispatcher'
import { encodePathAsUrl } from '../../lib/path'

View file

@ -1,5 +1,5 @@
import * as React from 'react'
import { CSSTransitionGroup } from 'react-transition-group'
import CSSTransitionGroup from 'react-transition-group/CSSTransitionGroup'
import { WindowState } from '../../lib/window-state'
interface IFullScreenInfoProps {

View file

@ -5,7 +5,7 @@ import {
getWindowState,
windowStateChannelName,
} from '../../lib/window-state'
import * as classNames from 'classnames'
import classNames from 'classnames'
// These paths are all drawn to a 10x10 view box and replicate the symbols
// seen on Windows 10 window controls.

View file

@ -1,5 +1,5 @@
import * as React from 'react'
import { CSSTransitionGroup } from 'react-transition-group'
import CSSTransitionGroup from 'react-transition-group/CSSTransitionGroup'
interface IZoomInfoProps {
readonly windowZoomFactor: number

View file

@ -1,4 +1,4 @@
import * as moment from 'moment'
import moment from 'moment'
import { BranchPruner } from '../../src/lib/stores/helpers/branch-pruner'
import { Repository } from '../../src/models/repository'
import { GitStoreCache } from '../../src/lib/stores/git-store-cache'

View file

@ -8,7 +8,7 @@ import {
getBranchCheckouts,
} from '../../../src/lib/git'
import { setupFixtureRepository } from '../../helpers/repositories'
import * as moment from 'moment'
import moment from 'moment'
import { GitProcess } from 'dugite'
async function createAndCheckout(

View file

@ -1,8 +1,8 @@
import * as path from 'path'
import * as HtmlWebpackPlugin from 'html-webpack-plugin'
import * as CleanWebpackPlugin from 'clean-webpack-plugin'
import * as webpack from 'webpack'
import * as merge from 'webpack-merge'
import HtmlWebpackPlugin from 'html-webpack-plugin'
import CleanWebpackPlugin from 'clean-webpack-plugin'
import webpack from 'webpack'
import merge from 'webpack-merge'
import { getChannel } from '../script/dist-info'
import { getReplacements } from './app-info'

View file

@ -1,7 +1,7 @@
import * as common from './webpack.common'
import * as webpack from 'webpack'
import * as merge from 'webpack-merge'
import merge from 'webpack-merge'
const config: webpack.Configuration = {
mode: 'development',

View file

@ -1,8 +1,8 @@
import * as common from './webpack.common'
import * as webpack from 'webpack'
import * as merge from 'webpack-merge'
import * as MiniCssExtractPlugin from 'mini-css-extract-plugin'
import merge from 'webpack-merge'
import MiniCssExtractPlugin from 'mini-css-extract-plugin'
import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer'
const MinifyPlugin = require('babel-minify-webpack-plugin')

View file

@ -4,7 +4,12 @@
import * as path from 'path'
import * as cp from 'child_process'
import * as fs from 'fs-extra'
import * as packager from 'electron-packager'
import packager, {
arch,
ElectronNotarizeOptions,
ElectronOsXSignOptions,
Options,
} from 'electron-packager'
import { externals } from '../app/webpack.common'
@ -126,7 +131,7 @@ interface IPackageAdditionalOptions {
readonly name: string
readonly schemes: ReadonlyArray<string>
}>
readonly osxSign: packager.ElectronOsXSignOptions & {
readonly osxSign: ElectronOsXSignOptions & {
readonly hardenedRuntime?: boolean
}
}
@ -143,7 +148,7 @@ function packageApp() {
)
}
const toPackageArch = (targetArch: string | undefined): packager.arch => {
const toPackageArch = (targetArch: string | undefined): arch => {
if (targetArch === undefined) {
return 'x64'
}
@ -172,7 +177,7 @@ function packageApp() {
)
}
const options: packager.Options & IPackageAdditionalOptions = {
const options: Options & IPackageAdditionalOptions = {
name: getExecutableName(),
platform: toPackagePlatform(process.platform),
arch: toPackageArch(process.env.TARGET_ARCH),
@ -442,9 +447,7 @@ ${licenseText}`
fs.removeSync(chooseALicense)
}
function getNotarizationCredentials():
| packager.ElectronNotarizeOptions
| undefined {
function getNotarizationCredentials(): ElectronNotarizeOptions | undefined {
const appleId = process.env.APPLE_ID
const appleIdPassword = process.env.APPLE_ID_PASSWORD
if (appleId === undefined || appleIdPassword === undefined) {

View file

@ -4,7 +4,7 @@ import { promisify } from 'util'
import { licenseOverrides } from './license-overrides'
import * as _legalEagle from 'legal-eagle'
import _legalEagle from 'legal-eagle'
const legalEagle = promisify(_legalEagle)
import { getVersion } from '../../app/package-info'

View file

@ -3,7 +3,7 @@
import * as Path from 'path'
import { spawnSync, SpawnSyncOptions } from 'child_process'
import * as glob from 'glob'
import glob from 'glob'
const root = Path.dirname(__dirname)

View file

@ -26,7 +26,7 @@ import * as Fs from 'fs'
import { execSync } from 'child_process'
import * as AWS from 'aws-sdk'
import * as Crypto from 'crypto'
import * as request from 'request'
import request from 'request'
console.log('Packaging…')
execSync('yarn package')

View file

@ -1,7 +1,7 @@
import * as express from 'express'
import * as webpack from 'webpack'
import * as devMiddleware from 'webpack-dev-middleware'
import * as hotMiddleware from 'webpack-hot-middleware'
import express from 'express'
import webpack from 'webpack'
import devMiddleware from 'webpack-dev-middleware'
import hotMiddleware from 'webpack-hot-middleware'
import { forceUnwrap as u } from '../app/src/lib/fatal-error'

View file

@ -2,6 +2,7 @@
"compilerOptions": {
"module": "commonjs",
"moduleResolution": "node",
"esModuleInterop": true,
"target": "es2017",
"allowUnreachableCode": false,
"allowUnusedLabels": false,

View file

@ -3,14 +3,14 @@
import * as Path from 'path'
import * as Fs from 'fs'
import * as Ajv from 'ajv'
import Ajv, { ErrorObject } from 'ajv'
function handleError(error: string) {
console.error(error)
process.exit(-1)
}
function formatErrors(errors: Ajv.ErrorObject[]): string {
function formatErrors(errors: ErrorObject[]): string {
return errors
.map(error => {
const { dataPath, message } = error

View file

@ -3,6 +3,7 @@
"module": "commonjs",
"moduleResolution": "node",
"target": "es2017",
"esModuleInterop": true,
"allowUnreachableCode": false,
"allowUnusedLabels": false,
"noImplicitReturns": true,