chore(deps): fix typescript configuration

This commit is contained in:
Luke Watts
2022-02-01 18:50:37 +01:00
parent 4b1b06d624
commit a58cb330ad
15 changed files with 85 additions and 22 deletions

View File

@@ -9,7 +9,7 @@ import {
IHowtoStats, IHowtoStats,
IUserDB, IUserDB,
IMapPin, IMapPin,
} from 'one-army-community-platform/lib/models' } from '../../src/models'
export { DBDoc, IDBEndpoint, IEventDB, IHowtoDB, IHowtoStats, IUserDB, IMapPin } export { DBDoc, IDBEndpoint, IEventDB, IHowtoDB, IHowtoStats, IUserDB, IMapPin }
import { generateDBEndpoints } from 'oa-shared' import { generateDBEndpoints } from 'oa-shared'

View File

@@ -18,8 +18,8 @@ export const handleUserUpdates = functions.firestore
}) })
async function processHowToUpdates(change: IDBDocChange) { async function processHowToUpdates(change: IDBDocChange) {
const info: IUserDB = change.after.exists ? change.after.data() : {} const info = (change.after.exists ? change.after.data() : {}) as IUserDB
const prevInfo: IUserDB = change.before.exists ? change.before.data() : {} const prevInfo = (change.before.exists ? change.before.data() : {}) as IUserDB
// optional chaining (.?.) incase does not exists // optional chaining (.?.) incase does not exists
const prevCountryCode = prevInfo.location?.countryCode const prevCountryCode = prevInfo.location?.countryCode
const newCountryCode = info.location?.countryCode const newCountryCode = info.location?.countryCode

View File

@@ -13,7 +13,9 @@
"skipLibCheck": true, "skipLibCheck": true,
"esModuleInterop": true, "esModuleInterop": true,
"allowSyntheticDefaultImports": true, "allowSyntheticDefaultImports": true,
"resolveJsonModule": true "resolveJsonModule": true,
"paths": {
}
}, },
"references": [ "references": [
// these (should) be compiled ahead of functions, although can break: https://github.com/microsoft/TypeScript/issues/25864#issuecomment-596217193 // these (should) be compiled ahead of functions, although can break: https://github.com/microsoft/TypeScript/issues/25864#issuecomment-596217193
@@ -21,6 +23,6 @@
{ "path": "../tsconfig.src-types.json" }, { "path": "../tsconfig.src-types.json" },
{ "path": "../shared/tsconfig.json" } { "path": "../shared/tsconfig.json" }
], ],
"include": ["src/**/*"], "include": ["src/**/*", "../types"],
"exclude": ["src/**/*.test.tsx", "../src/**/*.test.tsx"] "exclude": ["src/**/*.test.tsx", "../src/**/*.test.tsx"]
} }

View File

@@ -1,10 +1,10 @@
import * as React from 'react'; import * as React from 'react';
import { Icon, IGlyphs } from 'src/components/Icons' import { Icon, IGlyphs } from '../Icons'
import { import {
Button as RebassButton, Button as RebassButton,
ButtonProps as RebassButtonProps, ButtonProps as RebassButtonProps,
} from 'rebass/styled-components' } from 'rebass/styled-components'
import Text from 'src/components/Text' import Text from '../Text'
import styled from 'styled-components' import styled from 'styled-components'
// extend to allow any default button props (e.g. onClick) to also be passed // extend to allow any default button props (e.g. onClick) to also be passed

View File

@@ -4,9 +4,9 @@ import styled from 'styled-components'
import { Button } from '../Button' import { Button } from '../Button'
import 'react-image-lightbox/style.css' import 'react-image-lightbox/style.css'
import { ImageConverter } from './ImageConverter' import { ImageConverter } from './ImageConverter'
import theme from 'src/themes/styled.theme' import theme from '../../themes/styled.theme'
import Dropzone from 'react-dropzone' import Dropzone from 'react-dropzone'
import { IUploadedFileMeta } from 'src/stores/storage' import type { IUploadedFileMeta } from '../../stores/storage'
interface ITitleProps { interface ITitleProps {
hasUploadedImg: boolean hasUploadedImg: boolean

View File

@@ -2,7 +2,7 @@ import {
Text as RebassText, Text as RebassText,
TextProps as RebassTextProps, TextProps as RebassTextProps,
} from 'rebass/styled-components' } from 'rebass/styled-components'
import theme from 'src/themes/styled.theme' import theme from '../../themes/styled.theme'
import styled from 'styled-components' import styled from 'styled-components'
export interface ITextProps { export interface ITextProps {

View File

@@ -16,7 +16,7 @@ import type {
siteVariants, siteVariants,
} from './types'; } from './types';
import type { ConfigurationOption } from './constants'; import type { ConfigurationOption } from './constants';
import { UserRole } from 'src/models' import { UserRole } from '../models'
/** /**
* Helper function to load configuration property * Helper function to load configuration property

View File

@@ -1,6 +1,6 @@
import { ISelectedTags } from './tags.model' import { ISelectedTags } from './tags.model'
import { DBDoc, ISODateString, IModerable } from './common.models' import { DBDoc, ISODateString, IModerable } from './common.models'
import { ILocation } from 'src/models/common.models' import { ILocation } from './common.models'
export interface IEvent extends IEventFormInput, IModerable { export interface IEvent extends IEventFormInput, IModerable {
_createdBy: string _createdBy: string

View File

@@ -1,7 +1,7 @@
import { ISelectedTags } from './tags.model' import { ISelectedTags } from './tags.model'
import { DBDoc, IModerable } from './common.models' import { DBDoc, IModerable } from './common.models'
import { IConvertedFileMeta } from 'src/components/ImageInput/ImageInput' import type { IConvertedFileMeta } from '../components/ImageInput/ImageInput'
import { IUploadedFileMeta } from 'src/stores/storage' import type { IUploadedFileMeta } from '../stores/storage'
/** /**
* Comments are currently only used in Howtos. * Comments are currently only used in Howtos.

View File

@@ -5,8 +5,8 @@ import {
DBDoc, DBDoc,
IModerationStatus, IModerationStatus,
} from './common.models' } from './common.models'
import { IUploadedFileMeta } from 'src/stores/storage' import type { IUploadedFileMeta } from '../stores/storage'
import { IConvertedFileMeta } from 'src/components/ImageInput/ImageInput' import type { IConvertedFileMeta } from '../components/ImageInput/ImageInput'
export interface IUserState { export interface IUserState {
user?: IUser user?: IUser

View File

@@ -4,7 +4,7 @@
b) to enforce specific patterns when interacting with storage, such as setting metadata b) to enforce specific patterns when interacting with storage, such as setting metadata
*/ */
import { storage } from 'src/utils/firebase' import { storage } from '../utils/firebase'
export class Storage { export class Storage {
/****************************************************************************** * /****************************************************************************** *

View File

@@ -1,4 +1,4 @@
import type { ThemeWithName } from "../types" import { ThemeWithName } from "../types"
// use enum to specify list of possible colors for typing // use enum to specify list of possible colors for typing
export const colors = { export const colors = {

View File

@@ -1,4 +1,3 @@
import type { DefaultTheme } from 'styled-components'
interface LinkList { interface LinkList {
label: string label: string
url: string url: string
@@ -16,6 +15,63 @@ export interface PlatformTheme {
externalLinks: LinkList[] externalLinks: LinkList[]
} }
export interface ThemeWithName extends DefaultTheme { export interface ThemeWithName {
name: string; name: string;
/**
* Following properties are taken from DefaultTheme
* exported from `styled-components`
*
* This should ideally be imported rather than manually
* inlined. However some behaviour is making this hard to
* achieve at the moment.
*/
typography: {
auxiliary: any
paragraph: any
},
colors: {
white: string
black: string
primary: string
softyellow: string
yellow: { base: string; hover: string }
blue: string
red: string
red2: string
softblue: string
bluetag: string
grey: string
green: string
error: string
background: string
silver: string
softgrey: string
offwhite: string
lightgrey: string
}
fontSizes: number[]
space: number[]
radii: number[]
zIndex: {
behind: number
level: number
default: number
slickArrows: number
modalProfile: number
logoContainer: number
mapFlexBar: number
header: number
modalBackdrop: number
modalContent: number
}
breakpoints: string[]
buttons: any
maxContainerWidth: number
regular: number
bold: number
} }

View File

@@ -4,7 +4,7 @@ import 'firebase/auth'
import 'firebase/storage' import 'firebase/storage'
import 'firebase/functions' import 'firebase/functions'
import 'firebase/database' import 'firebase/database'
import { FIREBASE_CONFIG, SITE } from 'src/config/config' import { FIREBASE_CONFIG, SITE } from '../config/config'
// initialise with config settings, additional firestore config to support future changes // initialise with config settings, additional firestore config to support future changes
firebase.initializeApp(FIREBASE_CONFIG) firebase.initializeApp(FIREBASE_CONFIG)

View File

@@ -17,7 +17,12 @@
"noImplicitAny": false, "noImplicitAny": false,
"strictPropertyInitialization": false, "strictPropertyInitialization": false,
"experimentalDecorators": true, "experimentalDecorators": true,
"typeRoots": ["./node_modules/@types", "./types", "@testing-library/jest-dom"], "typeRoots": [
"./node_modules/@types",
"./types",
"@testing-library/jest-dom",
"../src/themes/types"
],
"declaration": true, "declaration": true,
"noEmit": true, "noEmit": true,
"noFallthroughCasesInSwitch": true, "noFallthroughCasesInSwitch": true,