Skip to content

Commit

Permalink
Merge pull request #8 from oshx/update/image-to-strings
Browse files Browse the repository at this point in the history
Added types of image format.
Updated a README.md.
Updated a version information.
  • Loading branch information
oshx authored Jul 29, 2024
2 parents c59b620 + d54b988 commit 59d3525
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 1 deletion.
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,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.
Expand Down Expand Up @@ -145,6 +149,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 <img src={sampleImage} />;
}
export default SomeImageElement;
```

The package includes example `JS-Doc`.

This package will promise to you below.
Expand Down
54 changes: 54 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@oshx/type-helper",
"version": "1.0.6",
"version": "1.0.7",
"description": "Types help TypeScript types.",
"repository": {
"type": "git",
Expand Down

0 comments on commit 59d3525

Please sign in to comment.