Skip to content
This repository was archived by the owner on Mar 4, 2020. It is now read-only.

Commit 636445d

Browse files
authored
chore: Normalize custom types (#2252)
1 parent cbe7db9 commit 636445d

40 files changed

+200
-200
lines changed

build/config.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import * as path from 'path'
22
import * as _ from 'lodash'
3+
import * as webpack from 'webpack'
34

45
// ------------------------------------
56
// Environment vars
@@ -21,12 +22,14 @@ const envConfig = {
2122
// ----------------------------------
2223
path_base: path.resolve(__dirname, '..'),
2324
dir_build: 'build',
25+
dir_docs: 'docs',
2426
dir_docs_dist: 'docs/dist',
2527
dir_docs_src: 'docs/src',
2628
dir_e2e: 'e2e',
2729
dir_e2e_src: 'e2e/server',
2830
dir_e2e_dist: 'e2e/dist',
2931
dir_packages: 'packages',
32+
dir_perf: 'perf',
3033
dir_perf_dist: 'perf/dist',
3134
dir_perf_src: 'perf/src',
3235
dir_umd_dist: 'dist/umd',
@@ -41,6 +44,7 @@ const fromBase = (...paths: string[]) => (...subPaths: string[]) => base(...path
4144

4245
const tempPaths = {
4346
build: fromBase(envConfig.dir_build),
47+
docs: fromBase(envConfig.dir_docs),
4448
docsDist: fromBase(envConfig.dir_docs_dist),
4549
docsSrc: fromBase(envConfig.dir_docs_src),
4650
e2e: fromBase(envConfig.dir_e2e),
@@ -51,6 +55,7 @@ const tempPaths = {
5155
packageSrc: (packageName: string, ...paths: string[]) =>
5256
base(envConfig.dir_packages, packageName, 'src', ...paths),
5357
packages: fromBase(envConfig.dir_packages),
58+
perf: fromBase(envConfig.dir_perf),
5459
perfDist: fromBase(envConfig.dir_perf_dist),
5560
perfSrc: fromBase(envConfig.dir_perf_src),
5661
umdDist: fromBase(envConfig.dir_umd_dist),
@@ -91,8 +96,8 @@ const config = {
9196
// ----------------------------------
9297
// Compiler Configuration
9398
// ----------------------------------
94-
compiler_devtool: __DEV__ && 'eval-source-map',
95-
compiler_mode: __DEV__ ? 'development' : 'production',
99+
compiler_devtool: __DEV__ && ('eval-source-map' as webpack.Options.Devtool),
100+
compiler_mode: (__DEV__ ? 'development' : 'production') as webpack.Configuration['mode'],
96101
compiler_globals: {
97102
__DEV__,
98103
__PERF__,

build/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
"@types/node": "^10.3.2",
2929
"@types/puppeteer": "^1.11.1",
3030
"@types/webpack-dev-middleware": "^2.0.1",
31+
"@types/webpack-env": "^1.14.1",
3132
"@types/webpack-hot-middleware": "^2.16.3",
3233
"@typescript-eslint/eslint-plugin": "^2.5.0",
3334
"@typescript-eslint/parser": "^2.5.0",

build/screener/screener.config.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1+
// @ts-check
2+
13
require('@fluentui/internal-tooling/babel/register')
24

35
const config = require('../config').default
4-
const { compilerOptions } = require('../tsconfig.docs.json')
6+
7+
const { compilerOptions } = require(config.paths.docs('tsconfig.json'))
58

69
require('tsconfig-paths').register({
710
baseUrl: config.path_base,

build/screener/screener.steps.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import fs from 'fs'
33
import Steps from 'screener-runner/src/steps'
44
import keys from 'screener-runner/src/keys'
55

6-
const DEFAULT_THEMES: ScreenerThemes = ['teams']
6+
const DEFAULT_THEMES: ScreenerThemeName[] = ['teams']
77

88
Steps.prototype.resetExternalLayout = function resetExternalLayout() {
99
return this.executeScript(`window.resetExternalLayout()`)

build/tsconfig.common.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
"@fluentui/*": ["packages/*/src"]
1313
},
1414
"types": ["node", "jest"],
15-
"typeRoots": ["../types", "../node_modules/@types"],
1615
"jsx": "react",
1716
"importHelpers": true,
1817
"isolatedModules": true,

build/tsconfig.docs.json

Lines changed: 0 additions & 13 deletions
This file was deleted.

build/tsconfig.e2e.json

Lines changed: 0 additions & 7 deletions
This file was deleted.

build/tsconfig.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
{
22
"extends": "./tsconfig.common.json",
33
"compilerOptions": {
4-
"allowSyntheticDefaultImports": true
4+
"allowSyntheticDefaultImports": true,
5+
"typeRoots": ["../types", "../node_modules/@types"],
6+
"types": ["node", "webpack-env", "screener-runner"]
57
}
68
}

build/tsconfig.perf.json

Lines changed: 0 additions & 7 deletions
This file was deleted.

build/tsconfig.test.json

Lines changed: 0 additions & 7 deletions
This file was deleted.

build/webpack.config.e2e.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import CopyWebpackPlugin from 'copy-webpack-plugin'
22
import ForkTsCheckerWebpackPlugin from 'fork-ts-checker-webpack-plugin'
33
import { webpack as lernaAliases } from 'lerna-alias'
4+
import webpack from 'webpack'
45

56
import config from './config'
67

78
const { paths } = config
89

9-
const webpackConfig: any = {
10+
const webpackConfig: webpack.Configuration = {
1011
name: 'client',
1112
target: 'web',
1213
mode: 'development',
@@ -18,7 +19,7 @@ const webpackConfig: any = {
1819
path: paths.e2eDist(),
1920
pathinfo: true,
2021
},
21-
devtool: config.compiler_devtool,
22+
devtool: config.compiler_devtool as webpack.Options.Devtool,
2223
node: {
2324
fs: 'empty',
2425
module: 'empty',
@@ -40,7 +41,7 @@ const webpackConfig: any = {
4041
],
4142
},
4243
plugins: [
43-
new ForkTsCheckerWebpackPlugin({ tsconfig: paths.build('tsconfig.e2e.json') }),
44+
new ForkTsCheckerWebpackPlugin({ tsconfig: paths.e2e('tsconfig.json') }),
4445
new CopyWebpackPlugin([
4546
{
4647
from: paths.e2eSrc('index.html'),

build/webpack.config.perf.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@ import CopyWebpackPlugin from 'copy-webpack-plugin'
22
import ForkTsCheckerWebpackPlugin from 'fork-ts-checker-webpack-plugin'
33
import { webpack as lernaAliases } from 'lerna-alias'
44
import { argv } from 'yargs'
5+
import webpack from 'webpack'
56

67
import config from './config'
78

89
const { paths } = config
910

10-
const webpackConfig: any = {
11+
const webpackConfig: webpack.Configuration = {
1112
name: 'client',
1213
target: 'web',
1314
mode: 'development',
@@ -20,7 +21,7 @@ const webpackConfig: any = {
2021
pathinfo: true,
2122
publicPath: config.compiler_public_path,
2223
},
23-
devtool: config.compiler_devtool,
24+
devtool: config.compiler_devtool as webpack.Options.Devtool,
2425
node: {
2526
fs: 'empty',
2627
module: 'empty',
@@ -42,7 +43,7 @@ const webpackConfig: any = {
4243
],
4344
},
4445
plugins: [
45-
new ForkTsCheckerWebpackPlugin({ tsconfig: paths.build('tsconfig.perf.json') }),
46+
new ForkTsCheckerWebpackPlugin({ tsconfig: paths.perf('tsconfig.json') }),
4647
new CopyWebpackPlugin([
4748
{
4849
from: paths.perfSrc('index.html'),

build/webpack.config.stats.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class IgnoreNotFoundExportPlugin {
2727
}
2828
}
2929

30-
const makeConfig = (srcPath, name) => ({
30+
const makeConfig = (srcPath: string, name: string): webpack.Configuration => ({
3131
mode: 'production',
3232
name: 'client',
3333
target: 'web',

build/webpack.config.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import config from './config'
1212
const { paths } = config
1313
const { __DEV__, __PROD__ } = config.compiler_globals
1414

15-
const webpackConfig: any = {
15+
const webpackConfig: webpack.Configuration = {
1616
name: 'client',
1717
target: 'web',
1818
mode: config.compiler_mode,
@@ -26,7 +26,7 @@ const webpackConfig: any = {
2626
pathinfo: true,
2727
publicPath: config.compiler_public_path,
2828
},
29-
devtool: config.compiler_devtool,
29+
devtool: config.compiler_devtool as webpack.Options.Devtool,
3030
externals: {
3131
'@babel/standalone': 'Babel',
3232
'anchor-js': 'AnchorJS',
@@ -68,7 +68,7 @@ const webpackConfig: any = {
6868
},
6969
plugins: [
7070
new ForkTsCheckerWebpackPlugin({
71-
tsconfig: paths.base('build/tsconfig.docs.json'),
71+
tsconfig: paths.docs('tsconfig.json'),
7272
watch: [paths.docsSrc(), paths.packages()],
7373
}),
7474
new webpack.DefinePlugin(config.compiler_globals),
@@ -112,7 +112,7 @@ const webpackConfig: any = {
112112
entries: true,
113113
modules: true,
114114
modulesCount: 500,
115-
}),
115+
} as any),
116116
].filter(Boolean),
117117
resolve: {
118118
extensions: ['.ts', '.tsx', '.js', '.json'],
@@ -141,7 +141,7 @@ const webpackConfig: any = {
141141
// Environment Configuration
142142
// ------------------------------------
143143
if (__DEV__) {
144-
const webpackHotPath = `${config.compiler_public_path}__webpack_hmr`
144+
const webpackHotPath = `${config.compiler_public_path}__compiler_hmr`
145145
const webpackHotMiddlewareEntry = `webpack-hot-middleware/client?${_.map(
146146
{
147147
path: webpackHotPath, // The path which the middleware is serving the event stream on
@@ -153,8 +153,9 @@ if (__DEV__) {
153153
},
154154
(val, key) => `&${key}=${val}`,
155155
).join('')}`
156+
const entry = webpackConfig.entry as webpack.Entry
157+
entry.app = [webpackHotMiddlewareEntry].concat((entry as webpack.Entry).app)
156158

157-
webpackConfig.entry.app = [webpackHotMiddlewareEntry].concat(webpackConfig.entry.app)
158159
webpackConfig.plugins.push(
159160
new webpack.HotModuleReplacementPlugin(),
160161
new webpack.NoEmitOnErrorsPlugin(),

build/webpack.config.umd.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1+
import webpack from 'webpack'
12
import config from './config'
23
import webpackConfig from './webpack.config'
34

45
const { paths } = config
56

6-
const webpackUMDConfig = (packageName: string) => {
7+
const webpackUMDConfig = (packageName: string): webpack.Configuration => {
78
const pkg = require(`../packages/${packageName}/package.json`)
89

910
return {

docs/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
"@types/node": "^10.3.2",
2929
"@types/react-custom-scrollbars": "^4.0.5",
3030
"@types/react-router-dom": "^4.3.4",
31+
"@types/webpack-env": "^1.14.1",
3132
"gulp": "^4.0.2"
3233
},
3334
"publishConfig": {

docs/src/components/DocsLayout.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Provider, themes, pxToRem, createTheme } from '@fluentui/react'
2+
// @ts-ignore
23
import AnchorJS from 'anchor-js'
34
import * as PropTypes from 'prop-types'
45
import * as React from 'react'

types/global.d.ts renamed to docs/src/global.d.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
1+
// Due to the react reference, putting these under /types doesn't work well
2+
3+
/* eslint-disable spaced-comment */
4+
/// <reference types="react" />
5+
16
declare const __DEV__: boolean
27
declare const __PATH_SEP__: string
38
declare const __BASENAME__: string
49

5-
declare interface NodeModule {
6-
hot: any
7-
}
8-
9-
declare interface NodeRequire {
10-
context: any
11-
}
12-
1310
declare module '*.json' {
1411
const value: any
1512
export default value

docs/src/utils/componentInfoContext.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { ComponentInfo } from '../types'
77
const requireContext = require.context('../componentInfo', true, /\.info\.json$/)
88

99
const keys: string[] = requireContext.keys()
10-
const infoObjects: ComponentInfo[] = keys.map(requireContext)
10+
const infoObjects = keys.map(requireContext) as ComponentInfo[]
1111

1212
const componentInfoContext: {
1313
byDisplayName: { [componentName: string]: ComponentInfo }

docs/tsconfig.json

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
11
{
2-
"extends": "../build/tsconfig.docs.json"
2+
"extends": "../build/tsconfig.common.json",
3+
"compilerOptions": {
4+
"module": "esnext",
5+
"paths": {
6+
"@fluentui/*": ["packages/*/src"],
7+
"docs/*": ["docs/*"],
8+
"src/*": ["packages/react/src/*"],
9+
"test/*": ["packages/react/test/*"]
10+
},
11+
"typeRoots": ["../types", "../node_modules/@types"],
12+
"types": ["node", "webpack-env", "screener-runner"]
13+
},
14+
"include": ["./src"]
315
}

e2e/tsconfig.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
"extends": "../build/tsconfig.common.json",
33
"compilerOptions": {
44
"module": "esnext",
5-
"allowSyntheticDefaultImports": true
5+
"allowSyntheticDefaultImports": true,
6+
"types": ["node", "jest", "webpack-env"]
67
},
7-
"include": ["../packages/react/src", "../e2e", "../types"]
8+
"include": ["."]
89
}

gulpfile.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import * as tsPaths from 'tsconfig-paths'
44

55
import config from './build/config'
66

7-
const { compilerOptions } = require('./build/tsconfig.docs.json')
7+
const { compilerOptions } = require(config.paths.docs('tsconfig.json'))
88

99
// add node_modules/.bin to the path so we can invoke .bin CLIs in tasks
1010
process.env.PATH =

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@
8181
"react": "^16.8.6",
8282
"react-dom": "^16.8.6",
8383
"satisfied": "^1.1.1",
84-
"simulant": "^0.2.2",
8584
"syncpack": "^4.5.4",
8685
"tsconfig-paths": "^3.7.0",
8786
"tslint": "^5.11.0",

packages/digest/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"moduleResolution": "node",
77
"declaration": true,
88
"skipLibCheck": true,
9-
"types": ["node", "react"],
9+
"types": ["node"],
1010
"baseUrl": ".",
1111
"allowSyntheticDefaultImports": true,
1212
"paths": {

packages/perf-test/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"@fluentui/digest": "^0.43.0",
1919
"@types/react": "^16.8.10",
2020
"@types/react-dom": "^16.8.3",
21+
"@types/webpack-env": "^1.14.1",
2122
"flamegrill": "^0.1.3",
2223
"ignore-not-found-export-webpack-plugin": "^1.0.1",
2324
"just-scripts": "^0.35.0"

packages/perf-test/tsconfig.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
2-
"extends": "../../build/tsconfig.docs.json",
2+
"extends": "../../docs/tsconfig.json",
33
"compilerOptions": {
44
"rootDir": "src",
55
"outDir": "lib",
6-
"types": ["node", "jest", "expect-puppeteer", "jest-environment-puppeteer"]
6+
"types": ["node", "jest", "expect-puppeteer", "jest-environment-puppeteer", "webpack-env"]
77
},
88
"include": ["src"],
99
"references": []

0 commit comments

Comments
 (0)