From 7d4c04db088d4ad92d6766adb42253f417426a4d Mon Sep 17 00:00:00 2001 From: kuzhelov Date: Mon, 24 Sep 2018 18:16:21 +0200 Subject: [PATCH 1/7] disable skipLibCheck --- build/gulp/tasks/test-projects.tsx | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/build/gulp/tasks/test-projects.tsx b/build/gulp/tasks/test-projects.tsx index 2054d06da6..9f9e2e56db 100644 --- a/build/gulp/tasks/test-projects.tsx +++ b/build/gulp/tasks/test-projects.tsx @@ -119,18 +119,12 @@ export default App; await runInTestApp(`yarn add ${paths.base(stardustPackageFilename)}`) log("Stardust is successfully added as test project's dependency.") - //////// ENABLE SKIP LIB CHECK FLAG /////// - log("STEP 3. Enable 'skipLibCheck' flag for test project's TS compiler") - - const tsconfigPath = testAppPath('tsconfig.json') - enableTsCompilerFlagSync(tsconfigPath, 'skipLibCheck') - //////// REFERENCE STARDUST COMPONENTS IN TEST APP's MAIN FILE /////// - log("STEP 4. Reference Stardust components in test project's App.tsx") + log("STEP 3. Reference Stardust components in test project's App.tsx") fs.writeFileSync(testAppPath('src', 'App.tsx'), appTSX) //////// BUILD TEST PROJECT /////// - log('STEP 5. Build test project..') + log('STEP 4. Build test project..') await runInTestApp(`yarn build`) log('Test project is built successfully!') From 47671873abb3c60197fcd4ff6950f51e8cb342fe Mon Sep 17 00:00:00 2001 From: kuzhelov Date: Mon, 24 Sep 2018 18:20:29 +0200 Subject: [PATCH 2/7] remove unused method --- build/gulp/tasks/test-projects.tsx | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/build/gulp/tasks/test-projects.tsx b/build/gulp/tasks/test-projects.tsx index 9f9e2e56db..cde89e44a7 100644 --- a/build/gulp/tasks/test-projects.tsx +++ b/build/gulp/tasks/test-projects.tsx @@ -50,17 +50,6 @@ const createReactApp = async (atTempDirectory: string, appName: string): Promise return appProjectPath } -const enableTsCompilerFlagSync = (tsconfigPath: string, flag: string) => { - const tsConfigAsJson = JSON.parse(`${fs.readFileSync(tsconfigPath)}`) - if (!tsConfigAsJson.compilerOptions) { - tsConfigAsJson.compilerOptions = {} - } - - tsConfigAsJson.compilerOptions[flag] = true - - fs.writeFileSync(tsconfigPath, JSON.stringify(tsConfigAsJson)) -} - // Tests the following scenario // - Create a new react test app // - Add Stardust as a app's dependency From f37353463e7c6e265c443b4e0882f22d0c948126 Mon Sep 17 00:00:00 2001 From: kuzhelov Date: Wed, 17 Oct 2018 14:37:17 +0200 Subject: [PATCH 3/7] update typescript version --- .../plugins/gulp-use-relative-import-paths.ts | 68 ------------------- build/gulp/tasks/dist.ts | 9 +-- package.json | 2 +- src/lib/factories.tsx | 4 +- types/theme.d.ts | 4 +- 5 files changed, 7 insertions(+), 80 deletions(-) delete mode 100644 build/gulp/plugins/gulp-use-relative-import-paths.ts diff --git a/build/gulp/plugins/gulp-use-relative-import-paths.ts b/build/gulp/plugins/gulp-use-relative-import-paths.ts deleted file mode 100644 index 6bedbf6a96..0000000000 --- a/build/gulp/plugins/gulp-use-relative-import-paths.ts +++ /dev/null @@ -1,68 +0,0 @@ -import * as path from 'path' -const g = require('gulp-load-plugins')() - -type BasePathProvider = { - base: (relativePath: string) => string -} - -type Config = { - forImportStartsWith: string - paths: BasePathProvider -} - -type Transform = (from: From) => To - -const replace = (line: string, what: RegExp, how: Transform) => { - let replacedLine = line - - let match = what.exec(line) - while (match != null) { - const replacement = how(match) - replacedLine = replacedLine.replace(match[0], replacement) - match = what.exec(line) - } - - return replacedLine -} - -const replaceInlinedImportPaths = (content: string, how: Transform) => { - const InlinedImportRegexp = /import\(['"]([^.].*?)['"]\)/g - - return content - .split('\n') - .map(line => - replace(line, InlinedImportRegexp, match => { - const originalImportStatement = match[0] - const originalImportPath = match[1] - - if (!originalImportPath) { - return originalImportStatement - } - - const modifiedImportPath = how(originalImportPath) - return originalImportStatement.replace(originalImportPath, modifiedImportPath) - }), - ) - .join('\n') -} - -export default ({ forImportStartsWith, paths }: Config) => - g.transform('utf8', (content, file) => { - const originalSrcFilePath = file.path - - const contentWithReplacement = replaceInlinedImportPaths(content, importPath => { - if (forImportStartsWith && !importPath.startsWith(forImportStartsWith)) { - return importPath - } - - const absoluteSrcImportPath = paths.base(importPath) - const relativeImportPath = path.relative( - path.dirname(originalSrcFilePath), - absoluteSrcImportPath, - ) - - return relativeImportPath.startsWith('.') ? relativeImportPath : `./${relativeImportPath}` - }) - - return contentWithReplacement - }) diff --git a/build/gulp/tasks/dist.ts b/build/gulp/tasks/dist.ts index 2c73f5a34f..b78eea4534 100644 --- a/build/gulp/tasks/dist.ts +++ b/build/gulp/tasks/dist.ts @@ -8,7 +8,6 @@ import config from '../../../config' const { paths } = config const g = require('gulp-load-plugins')() const { log, PluginError } = g.util -import gulpUseRelativeImportPaths from '../plugins/gulp-use-relative-import-paths' // ---------------------------------------- // Clean @@ -30,9 +29,7 @@ task('build:dist:commonjs', () => { const types = src(paths.base('types/**')) return merge2([ - dts - .pipe(gulpUseRelativeImportPaths({ forImportStartsWith: 'src', paths })) - .pipe(dest(paths.dist('commonjs'))), + dts.pipe(dest(paths.dist('commonjs'))), js.pipe(dest(paths.dist('commonjs'))), types.pipe(dest(paths.dist('types'))), ]) @@ -47,9 +44,7 @@ task('build:dist:es', () => { const types = src(paths.base('types/**')) return merge2([ - dts - .pipe(gulpUseRelativeImportPaths({ forImportStartsWith: 'src', paths })) - .pipe(dest(paths.dist('es'))), + dts.pipe(dest(paths.dist('es'))), js.pipe(dest(paths.dist('es'))), types.pipe(dest(paths.dist('types'))), ]) diff --git a/package.json b/package.json index 260ba34617..70a75f1979 100644 --- a/package.json +++ b/package.json @@ -164,7 +164,7 @@ "ts-node": "^6.1.0", "tslint": "^5.10.0", "tslint-config-airbnb": "^5.9.2", - "typescript": "^3.0.1", + "typescript": "~3.1.0", "webpack": "^3.5.4", "webpack-dev-middleware": "^1.12.0", "webpack-hot-middleware": "^2.18.2" diff --git a/src/lib/factories.tsx b/src/lib/factories.tsx index 3a2a4f872b..1204293550 100644 --- a/src/lib/factories.tsx +++ b/src/lib/factories.tsx @@ -20,7 +20,7 @@ interface ICreateShorthandOptions { defaultProps?: IProps /** Override props object or function (called with regular props) */ - overrideProps?: IProps | ((props: IProps) => IProps) + overrideProps?: IProps & ((props: IProps) => IProps) | IProps /** Whether or not automatic key generation is allowed */ generateKey?: boolean @@ -86,7 +86,7 @@ export function createShorthand( let { overrideProps } = options overrideProps = typeof overrideProps === 'function' - ? overrideProps({ ...defaultProps, ...usersProps }) + ? (overrideProps as Function)({ ...defaultProps, ...usersProps }) : overrideProps || {} // Merge props diff --git a/types/theme.d.ts b/types/theme.d.ts index d9cffb108d..75cb7e7ab0 100644 --- a/types/theme.d.ts +++ b/types/theme.d.ts @@ -164,7 +164,7 @@ export interface IThemePrepared { } export interface IThemeComponentStylesInput { - [key: string]: IComponentPartStylesInput + [key: string]: IComponentPartStylesInput | undefined Accordion?: IComponentPartStylesInput Attachment?: IComponentPartStylesInput @@ -199,7 +199,7 @@ export interface IThemeComponentStylesInput { } export interface IThemeComponentStylesPrepared { - [key: string]: IComponentPartStylesPrepared + [key: string]: IComponentPartStylesPrepared | undefined Accordion?: IComponentPartStylesPrepared Attachment?: IComponentPartStylesPrepared From 5214dc27f08c176805169b589e1f90335c1eda5b Mon Sep 17 00:00:00 2001 From: kuzhelov Date: Wed, 17 Oct 2018 14:37:46 +0200 Subject: [PATCH 4/7] imporve cra-ts test project's logic --- build/gulp/tasks/test-projects.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/build/gulp/tasks/test-projects.tsx b/build/gulp/tasks/test-projects.tsx index cde89e44a7..a624112103 100644 --- a/build/gulp/tasks/test-projects.tsx +++ b/build/gulp/tasks/test-projects.tsx @@ -97,7 +97,9 @@ export default App; //////// CREATE TEST REACT APP /////// log('STEP 1. Create test React project with TSX scripts..') - const testAppPath = paths.withRootAt(await createReactApp(tmp.dirSync().name, 'test-app')) + const testAppPath = paths.withRootAt( + await createReactApp(tmp.dirSync({ prefix: 'stardust-' }).name, 'test-app'), + ) const runInTestApp = runIn(testAppPath()) log(`Test React project is successfully created: ${testAppPath()}`) @@ -105,7 +107,7 @@ export default App; //////// ADD STARDUST AS A DEPENDENCY /////// log('STEP 2. Add Stardust dependency to test project..') - await runInTestApp(`yarn add ${paths.base(stardustPackageFilename)}`) + await runInTestApp(`npm install add ${paths.base(stardustPackageFilename)}`) log("Stardust is successfully added as test project's dependency.") //////// REFERENCE STARDUST COMPONENTS IN TEST APP's MAIN FILE /////// From cc6f81b7de814353cbfd862c8c315742e1aacecc Mon Sep 17 00:00:00 2001 From: kuzhelov Date: Wed, 17 Oct 2018 14:41:33 +0200 Subject: [PATCH 5/7] update yarn lock --- yarn.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/yarn.lock b/yarn.lock index 2111ea8408..61ca87d589 100644 --- a/yarn.lock +++ b/yarn.lock @@ -9341,10 +9341,10 @@ typedarray@^0.0.6: resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777" integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c= -typescript@^3.0.1: - version "3.0.1" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.0.1.tgz#43738f29585d3a87575520a4b93ab6026ef11fdb" - integrity sha512-zQIMOmC+372pC/CCVLqnQ0zSBiY7HHodU7mpQdjiZddek4GMj31I3dUJ7gAs9o65X7mnRma6OokOkc6f9jjfBg== +typescript@~3.1.0: + version "3.1.3" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.1.3.tgz#01b70247a6d3c2467f70c45795ef5ea18ce191d5" + integrity sha512-+81MUSyX+BaSo+u2RbozuQk/UWx6hfG0a5gHu4ANEM4sU96XbuIyAB+rWBW1u70c6a5QuZfuYICn3s2UjuHUpA== ua-parser-js@^0.7.18: version "0.7.18" From 0b0a0f8688d6b9228c797039d12cb6eb9da0c417 Mon Sep 17 00:00:00 2001 From: kuzhelov Date: Wed, 17 Oct 2018 18:22:23 +0200 Subject: [PATCH 6/7] use 'yarn add' for now --- build/gulp/tasks/test-projects.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/gulp/tasks/test-projects.tsx b/build/gulp/tasks/test-projects.tsx index a624112103..6410308906 100644 --- a/build/gulp/tasks/test-projects.tsx +++ b/build/gulp/tasks/test-projects.tsx @@ -107,7 +107,7 @@ export default App; //////// ADD STARDUST AS A DEPENDENCY /////// log('STEP 2. Add Stardust dependency to test project..') - await runInTestApp(`npm install add ${paths.base(stardustPackageFilename)}`) + await runInTestApp(`yarn add ${paths.base(stardustPackageFilename)}`) log("Stardust is successfully added as test project's dependency.") //////// REFERENCE STARDUST COMPONENTS IN TEST APP's MAIN FILE /////// From ab0d23d50470eb7278c5ec88d7072669b5d9d1bb Mon Sep 17 00:00:00 2001 From: kuzhelov Date: Wed, 17 Oct 2018 19:43:22 +0200 Subject: [PATCH 7/7] update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e051438d4b..2acb5718fc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm ### Fixes - Fix for cropped rounded corners in `Menu` component @Bugaa92 ([#360](https://github.com/stardust-ui/react/pull/360)) - Remove hardcoded `status` size calculations in `Avatar` component @Bugaa92 ([#358](https://github.com/stardust-ui/react/pull/358)) +- Remove necessity to use `skipLibCheck` flag for client's typescript projects that consume Stardust @kuzhelov ([#367](https://github.com/stardust-ui/react/pull/367)) ### Features - Add `target` prop to `Popup` @kuzhelog ([#356](https://github.com/stardust-ui/react/pull/356))