Skip to content
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

@damassi => Upgrades typescript and enables type emitting #715

Merged
merged 9 commits into from
Jun 4, 2018
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion externals/metaphysics
Submodule metaphysics updated 40 files
+0 −3 .env.example
+3 −11 package.json
+0 −9 src/config.js
+1 −13 src/data/complete.queryMap.json
+9 −41 src/index.js
+1 −1 src/lib/__tests__/cache.test.js
+0 −64 src/lib/__tests__/crunchInterceptor.test.js
+0 −200 src/lib/__tests__/graphqlTimeoutMiddleware.test.ts
+8 −39 src/lib/cache.js
+0 −17 src/lib/crunchInterceptor.js
+0 −1 src/lib/graphqlErrorHandler.js
+0 −49 src/lib/graphqlTimeoutMiddleware.ts
+0 −5 src/lib/loaders/api/index.js
+2 −2 src/lib/loaders/api/loader_with_authentication_factory.js
+3 −2 src/lib/loaders/api/loader_without_authentication_factory.js
+0 −1 src/lib/loaders/loaders_with_authentication/gravity.js
+0 −1 src/lib/loaders/loaders_without_authentication/gravity.js
+0 −16 src/lib/logQueryDetails.ts
+0 −1 src/lib/loggers.js
+73 −37 src/lib/tracer.js
+1 −48 src/schema/artwork/__tests__/artwork.test.js
+6 −18 src/schema/artwork/index.js
+2 −2 src/schema/collection.js
+8 −85 src/schema/home/__tests__/home_page_artwork_modules.test.js
+0 −2 src/schema/home/context.js
+0 −6 src/schema/home/home_page_artwork_modules.js
+0 −23 src/schema/home/results.js
+0 −2 src/schema/home/title.js
+0 −2 src/schema/index.js
+19 −99 src/schema/me/__tests__/bidder_position.test.js
+2 −2 src/schema/me/__tests__/bidder_position_mutation.test.js
+0 −73 src/schema/me/__tests__/create_bidder_mutation.test.js
+3 −38 src/schema/me/bidder_position.js
+0 −45 src/schema/me/bidder_position_messages.js
+66 −11 src/schema/me/bidder_position_mutation.js
+0 −30 src/schema/me/create_bidder_mutation.js
+0 −20 src/schema/types/bidder_position_result.js
+0 −39 src/test/gql-server.js
+0 −7 src/test/interceptor.js
+25 −305 yarn.lock
11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@
},
"scripts": {
"clean": "rm -rf dist",
"compile": "babel src --out-dir dist --copy-files -s --source-map --extensions '.js,.jsx,.ts,.tsx' --ignore src/**/__tests__,src/**/__stories__",
"compile": "tsc",
"deploy-storybook": "yarn relay && NODE_ENV=production storybook-to-ghpages",
"emit-types": "tsc --declaration --emitDeclarationOnly --listEmittedFiles --outDir dist",
"lint": "tslint -c tslint.json --project tsconfig.json",
"prepare": "patch-package",
"precommit": "lint-staged",
Expand All @@ -43,7 +44,7 @@
"test": "node verify-node-version.js && jest",
"test:watch": "jest --watch --runInBand",
"type-check": "tsc --noEmit --pretty",
"watch": "concurrently --raw --kill-others 'yarn relay --watch' 'yarn compile -w'",
"watch": "concurrently --kill-others 'yarn relay --watch' 'yarn compile -w'",
"semantic-release": "semantic-release"
},
"resolutions": {
Expand Down Expand Up @@ -117,14 +118,14 @@
"relay-compiler": "https://github.com/alloy/relay/releases/download/v1.5.0-artsy.3/relay-compiler-1.5.0-artsy.3.tgz",
"relay-compiler-language-typescript": "^0.9.0",
"semantic-release": "^12.4.1",
"styled-components": "^3.2.6",
"styled-components": "^3.3.2",
"ts-jest": "^22.4.6",
"ts-loader": "^3.5.0",
"tslint": "^4.5.0",
"tslint-config-prettier": "^1.1.0",
"tslint-react": "^2.4.0",
"typescript": "^2.6.2",
"typescript-styled-plugin": "^0.1.2",
"typescript": "^2.9.1",
"typescript-styled-plugin": "^0.6.3",
"webpack-bundle-analyzer": "^2.13.1",
"webpack-merge": "^4.1.0"
},
Expand Down
4 changes: 2 additions & 2 deletions src/Assets/Checkmark.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import React, { HTMLProps } from "react"

interface CheckmarkProps extends HTMLProps<SVGElement> {
export interface CheckmarkProps extends HTMLProps<SVGElement> {
stroke?: string
}

export class Checkmark extends React.Component<CheckmarkProps> {
render() {
const { stroke, ...remainderProps } = this.props
const { stroke, ref, ...remainderProps } = this.props

return (
<svg width={14} height={11} viewBox="0 0 14 11" {...remainderProps}>
Expand Down
9 changes: 5 additions & 4 deletions src/Components/Artist/MarketDataSummary/MarketDataSummary.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import { groupBy } from "lodash"
import * as React from "react"
import { createFragmentContainer, graphql } from "react-relay"
import styled from "styled-components"

// @ts-ignore
import { ComponentRef, createFragmentContainer, graphql } from "react-relay"
// @ts-ignore
import styled, { StyledComponentClass } from "styled-components"
import { unica } from "Assets/Fonts"

export const MarketDataSummaryContainer = styled.div`
${unica("s14")};
`
import { MarketDataSummary_artist } from "../../../__generated__/MarketDataSummary_artist.graphql"
interface Props extends React.HTMLProps<MarketDataSummary> {
export interface Props extends React.HTMLProps<MarketDataSummary> {
artist: MarketDataSummary_artist
onEmptyText?: string
}
Expand Down
2 changes: 1 addition & 1 deletion src/Components/Artist/MarketDataSummary/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { graphql, QueryRenderer } from "react-relay"
import { ContextConsumer, ContextProps } from "../../Artsy"
import MarketDataSummary from "./MarketDataSummary"

interface Props extends ContextProps {
export interface Props extends ContextProps {
artistID: string
}

Expand Down
2 changes: 1 addition & 1 deletion src/Components/Artist/MarketInsights/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { graphql, QueryRenderer } from "react-relay"
import { ContextConsumer, ContextProps } from "../../Artsy"
import MarketInsights from "./MarketInsights"

interface Props extends ContextProps {
export interface Props extends ContextProps {
artistID: string
}

Expand Down
9 changes: 5 additions & 4 deletions src/Components/Artwork/Details.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from "react"
import { createFragmentContainer, graphql } from "react-relay"
// @ts-ignore
import { ComponentRef, createFragmentContainer, graphql } from "react-relay"
import TextLink from "../TextLink"

import styled from "styled-components"
Expand All @@ -11,7 +12,7 @@ const TruncatedLine = styled.div`
white-space: nowrap;
`

interface Props extends RelayProps, React.HTMLProps<Details> {
export interface Props extends RelayProps, React.HTMLProps<Details> {
showSaleLine: boolean
}

Expand Down Expand Up @@ -99,7 +100,7 @@ export class Details extends React.Component<Props, null> {
}
}

export default createFragmentContainer(
export default createFragmentContainer<Props>(
Details,
graphql`
fragment Details_artwork on Artwork {
Expand Down Expand Up @@ -128,7 +129,7 @@ export default createFragmentContainer(
`
)

interface RelayProps {
export interface RelayProps {
artwork: {
href: string | null
title: string | null
Expand Down
17 changes: 12 additions & 5 deletions src/Components/Artwork/FillwidthItem.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import React from "react"
import { createFragmentContainer, graphql } from "react-relay"
import styled from "styled-components"
// @ts-ignore
import { ComponentRef, createFragmentContainer, graphql } from "react-relay"
// @ts-ignore
import styled, { StyledComponentClass } from "styled-components"

import RelayMetadata, { Metadata } from "./Metadata"
import RelaySaveButton, { SaveButton } from "./Save"
Expand All @@ -21,15 +23,20 @@ const Placeholder = styled.div`
width: 100%;
`

interface Props extends RelayProps, React.HTMLProps<FillwidthItemContainer> {
export interface FillwidthItemContainerProps
extends RelayProps,
React.HTMLProps<FillwidthItemContainer> {
targetHeight?: number
imageHeight?: number
width?: number
margin?: number
useRelay?: boolean
}

class FillwidthItemContainer extends React.Component<Props, null> {
export class FillwidthItemContainer extends React.Component<
FillwidthItemContainerProps,
null
> {
static defaultProps = {
useRelay: true,
}
Expand Down Expand Up @@ -94,7 +101,7 @@ export default createFragmentContainer(
`
)

interface RelayProps {
export interface RelayProps {
artwork: {
href: string | null
image: {
Expand Down
5 changes: 3 additions & 2 deletions src/Components/Artwork/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from "react"
import { createFragmentContainer, graphql } from "react-relay"
// @ts-ignore
import { ComponentRef, createFragmentContainer, graphql } from "react-relay"
import styled, { css } from "styled-components"

import theme from "../../Assets/Theme"
Expand Down Expand Up @@ -143,7 +144,7 @@ export default createFragmentContainer(
`
)

interface RelayProps {
export interface RelayProps {
artwork: {
id: string | null
image: {
Expand Down
22 changes: 14 additions & 8 deletions src/Components/ArtworkGrid.tsx
Original file line number Diff line number Diff line change
@@ -1,24 +1,30 @@
import React from "react"
import ReactDOM from "react-dom"
import { createFragmentContainer, graphql } from "react-relay"
import styled from "styled-components"

// @ts-ignore
import { ComponentRef, createFragmentContainer, graphql } from "react-relay"
// @ts-ignore
import styled, { StyledComponentClass } from "styled-components"
import RelayGridItem, { ArtworkGridItem } from "./Artwork/GridItem"

interface Props extends RelayProps, React.HTMLProps<ArtworkGridContainer> {
export interface ArtworkGridContainerProps
extends RelayProps,
React.HTMLProps<ArtworkGridContainer> {
columnCount?: number
sectionMargin?: number
itemMargin?: number
onLoadMore?: () => any
useRelay?: boolean
}

interface State {
export interface ArtworkGridContainerState {
loading: boolean
interval: any
}

class ArtworkGridContainer extends React.Component<Props, State> {
export class ArtworkGridContainer extends React.Component<
ArtworkGridContainerProps,
ArtworkGridContainerState
> {
static defaultProps = {
columnCount: 3,
sectionMargin: 20,
Expand Down Expand Up @@ -168,14 +174,14 @@ export default createFragmentContainer(
`
)

interface ArtworkRelayProps {
export interface ArtworkRelayProps {
__id: string
image: {
aspect_ratio: number | null
} | null
}

interface RelayProps {
export interface RelayProps {
artworks: {
edges: Array<{
node: any
Expand Down
13 changes: 9 additions & 4 deletions src/Components/BorderedPulldown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,28 @@ import React from "react"

import Icon from "./Icon"

import styled from "styled-components"
// @ts-ignore
import styled, { StyledComponentClass } from "styled-components"
import colors from "../Assets/Colors"
import { garamond } from "../Assets/Fonts"

interface Props extends React.HTMLProps<BorderedPulldown> {
export interface BorderedPullDownProps
extends React.HTMLProps<BorderedPulldown> {
options: any
defaultValue: string
onChange?: any
selectedName?: string
}

interface State {
export interface BorderedPulldownState {
selected: any
isHovered: boolean
}

export class BorderedPulldown extends React.Component<Props, State> {
export class BorderedPulldown extends React.Component<
BorderedPullDownProps,
BorderedPulldownState
> {
state = {
selected: null,
isHovered: false,
Expand Down
5 changes: 3 additions & 2 deletions src/Components/Buttons/Default.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from "react"
import styled from "styled-components"
// @ts-ignore
import styled, { StyledComponentClass } from "styled-components"
import colors from "Assets/Colors"
import { avantgarde } from "Assets/Fonts"
import { block } from "../Helpers"
Expand All @@ -19,7 +20,7 @@ export enum ButtonState {
Failure,
}

class Button extends React.Component<ButtonProps, any> {
export class Button extends React.Component<ButtonProps, any> {
public static defaultProps: ButtonProps

render(): JSX.Element {
Expand Down
3 changes: 2 additions & 1 deletion src/Components/Buttons/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Button from "./Default"
// @ts-ignore
import Button, { ButtonProps } from "./Default"
import FacebookButton from "./Facebook"
import GhostButton from "./Ghost"
import InvertedButton from "./Inverted"
Expand Down
2 changes: 1 addition & 1 deletion src/Components/Checkbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import colors from "../Assets/Colors"
import { Checkmark } from "Assets/Checkmark"
import { garamond } from "Assets/Fonts"

interface CheckboxState {
export interface CheckboxState {
checked: boolean
}

Expand Down
22 changes: 11 additions & 11 deletions src/Components/Gene/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,32 @@ import { ContextConsumer, ContextProps } from "../Artsy"
import Artists from "./Artists"
import GeneArtworks from "./GeneArtworks"

interface Filters {
export interface Filters {
for_sale: boolean
dimension_range: string
price_range: string
medium: string
medium?: string
}

type Sort = "year" | "-year" | "-partner_updated_at"
export type Sort = "year" | "-year" | "-partner_updated_at"

type Mode = "artists" | "artworks"
export type Mode = "artists" | "artworks"

interface StateChangePayload {
export interface StateChangePayload {
filters: Filters
sort: Sort
mode: Mode
}

interface Props extends ContextProps {
export interface Props extends ContextProps {
mode: Mode
filters?: Partial<Filters>
geneID: string
sort?: Sort
onStateChange: (payload: StateChangePayload) => void
}

interface State extends Filters {
export interface State extends Filters {
mode: Mode
sort?: Sort
}
Expand Down Expand Up @@ -75,17 +75,17 @@ class GeneContents extends React.Component<Props, State> {
// Because `for_sale` is a proper filter of its own, but
// we include its aggregation as part of `price_range`, we
// have to handle it specially.
onDropdownSelect(slice: string, value: string) {
let filter = slice.toLowerCase() as any
onDropdownSelect(slice: string, value: string | boolean) {
let filter = slice.toLowerCase() as string
if (filter === "price_range" && value === "*-*") {
filter = "for_sale"
value = "true"
value = true
}
this.setState(
{
[filter]: value,
mode: "artworks",
},
} as any,
this.handleStateChange
)
}
Expand Down
3 changes: 2 additions & 1 deletion src/Components/Icon.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from "react"
// @ts-ignore
import React, { StatelessComponent } from "react"
import styled from "styled-components"
import "../Assets/Fonts"
import icons, { IconName } from "../Assets/Icons"
Expand Down
4 changes: 2 additions & 2 deletions src/Components/Input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export interface InputProps extends React.HTMLProps<HTMLInputElement> {
rightView?: JSX.Element
}

interface InputState {
export interface InputState {
focused: boolean
value: string
showPassword: boolean
Expand Down Expand Up @@ -51,7 +51,7 @@ interface InputState {
* type="text"
* />
*/
class Input extends React.Component<InputProps, InputState> {
export class Input extends React.Component<InputProps, InputState> {
state = {
focused: false,
value: "",
Expand Down
Loading