From 09429eb6706f3f76431d9983dcfd9d0c083ed662 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=98=A4=EC=8A=B9=ED=99=98?= Date: Mon, 29 Jul 2024 22:13:24 +0900 Subject: [PATCH 1/5] Added types of image format. --- index.d.ts | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/index.d.ts b/index.d.ts index 0a51dcc..b2fe6dd 100644 --- a/index.d.ts +++ b/index.d.ts @@ -45,3 +45,57 @@ declare type PropsWithClassName< * } */ declare type AnyFunction = (...args: any[]) => any + +/** Image File Format GIF + * + * @example + * import example from '~/statics/example.gif'; + */ +declare module '*.gif' { + export default string +} + +/** Image File Format JPG + * + * @example + * import example from '~/statics/example.jpg'; + */ +declare module '*.jpg' { + export default string +} + +/** Image File Format JPEG + * + * @example + * import example from '~/statics/example.jpeg'; + */ +declare module '*.jpeg' { + export default string +} + +/** Image File Format PNG + * + * @example + * import example from '~/statics/example.png'; + */ +declare module '*.png' { + export default string +} + +/** Image File Format BMP + * + * @example + * import example from '~/statics/example.bmp'; + */ +declare module '*.bmp' { + export default string +} + +/** Image File Format WEBP + * + * @example + * import example from '~/statics/example.webp'; + */ +declare module '*.webp' { + export default string +} \ No newline at end of file From 0849678eb5f14593da31b466c8a133b73073e9e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=98=A4=EC=8A=B9=ED=99=98?= Date: Mon, 29 Jul 2024 22:25:36 +0900 Subject: [PATCH 2/5] Updated a README.md. --- README.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/README.md b/README.md index 47f9c9a..5f1b3e0 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,10 @@ type AnyFunction // simply declared any function ``` +```typescript +// images like GIF, JPG, JPEG, PNG, BMP, WEBP as string module +``` + ## Why it comes for? The inspiration of this package is built for practical uses when often occurred. @@ -134,6 +138,20 @@ function FunctionStyleComponent({ It should be useful when you make a component with '[Styled Components](https://styled-components.com/)' | '[Emotion Styled](https://emotion.sh/docs/styled)' +And also you can use your image components like below with '[React](https://react.dev/)'! + +```typescript jsx +// import with no errors! +import sampleImage from '~/statics/sample-image.gif'; + +// just use that image! +function SomeImageElement(): ReactElement { + return ; +} + +export default SomeImageElement; +``` + The package includes example `JS-Doc`. This package will promise to you below. From 31d1f86bf6b36d93d2f59b2cd75b0d54ade611db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=98=A4=EC=8A=B9=ED=99=98?= Date: Mon, 29 Jul 2024 22:26:06 +0900 Subject: [PATCH 3/5] Updated a version information. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 5f5156e..1cc3301 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@oshx/type-helper", - "version": "1.0.5", + "version": "1.0.7", "description": "Types help TypeScript types.", "repository": { "type": "git", From 431c4d019198af907daa71c2001ff0f7786cc69a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=98=A4=EC=8A=B9=ED=99=98?= Date: Mon, 22 Jul 2024 01:39:04 +0900 Subject: [PATCH 4/5] Updated README.md. --- README.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/README.md b/README.md index 5f1b3e0..482336a 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,17 @@ $ npm i -D @oshx/type-helper Please add below in `tsconfig.json` file. ```json +{ + "compilerOptions": { + "typeRoots": [ + "node_modules/@oshx" + ] + } +} +``` + +If your TypeScript doesn't accept that type, then add below. +```json { "compilerOptions": { "typeRoots": [ From 2f5583b2a0c55cfd19a7e8b041a396a88bfe65b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=98=A4=EC=8A=B9=ED=99=98?= Date: Mon, 22 Jul 2024 01:39:51 +0900 Subject: [PATCH 5/5] Updated 'PropsWithClassName' type as an optional value. --- index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.d.ts b/index.d.ts index b2fe6dd..d20f564 100644 --- a/index.d.ts +++ b/index.d.ts @@ -32,9 +32,9 @@ declare type ObjectValue = T[ObjectKey] */ declare type PropsWithClassName< T extends object = object, - ClassNameType = string | undefined + ClassNameType = string > = { - className: ClassNameType + className?: ClassNameType } & T /** The simple `Any function` declaration.