-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes type definitions @astrojs/image
and adds more documentation to the README
#4045
Merged
Merged
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
ced02ac
WIP: moving to a static .d.ts types file
e72d2b1
fixing named exports for getImage and getPicture
97ce8f9
removing the exports.astro map for now
bbfe181
WIP: adding readme docs for component attributes
cc4fe95
Adding docs for getImage and getPicture
f2c2ec2
Merge branch 'main' into fix/image-types
f418fcf
Merge branch 'main' into fix/image-types
4aeb4f8
Merge branch 'main' into fix/image-types
966da18
leaning fully on TSC to build .d.ts files
7ba8469
finally found the solution for proper ESM import types
2a9de43
adding a note to the README for tsconfig updates
2632086
chore: add changesets
606ea33
typo
5865b15
docs: removing the "Images in Markdown" example
0381da2
Merge branch 'main' into fix/image-types
6a4e82c
removing the need for publishing src to NPM
3aa2210
Merge branch 'fix/image-types' of github.com:withastro/astro into fix…
cdf48f2
fix: make type re-export explicit
ae6d203
updating image module defs to match InputFormat
0aadefe
using astro syntax highlighting for README code blocks
ef0361f
nit: missing backtick in README
01d18e0
make sure Astro component directives aren't recommended twice
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'astro': patch | ||
--- | ||
|
||
Adding support for custom "astro/client" type definitions in `@astrojs/image` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@astrojs/image': minor | ||
--- | ||
|
||
Big improvements to the TypeScript and Language Tools support for `@astrojs/image` :tada: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,173 @@ | ||
/// <reference types="vite/types/importMeta" /> | ||
|
||
// CSS modules | ||
type CSSModuleClasses = { readonly [key: string]: string }; | ||
|
||
declare module '*.module.css' { | ||
const classes: CSSModuleClasses; | ||
export default classes; | ||
} | ||
declare module '*.module.scss' { | ||
const classes: CSSModuleClasses; | ||
export default classes; | ||
} | ||
declare module '*.module.sass' { | ||
const classes: CSSModuleClasses; | ||
export default classes; | ||
} | ||
declare module '*.module.less' { | ||
const classes: CSSModuleClasses; | ||
export default classes; | ||
} | ||
declare module '*.module.styl' { | ||
const classes: CSSModuleClasses; | ||
export default classes; | ||
} | ||
declare module '*.module.stylus' { | ||
const classes: CSSModuleClasses; | ||
export default classes; | ||
} | ||
declare module '*.module.pcss' { | ||
const classes: CSSModuleClasses; | ||
export default classes; | ||
} | ||
|
||
// CSS | ||
declare module '*.css' { | ||
const css: string; | ||
export default css; | ||
} | ||
declare module '*.scss' { | ||
const css: string; | ||
export default css; | ||
} | ||
declare module '*.sass' { | ||
const css: string; | ||
export default css; | ||
} | ||
declare module '*.less' { | ||
const css: string; | ||
export default css; | ||
} | ||
declare module '*.styl' { | ||
const css: string; | ||
export default css; | ||
} | ||
declare module '*.stylus' { | ||
const css: string; | ||
export default css; | ||
} | ||
declare module '*.pcss' { | ||
const css: string; | ||
export default css; | ||
} | ||
|
||
// Built-in asset types | ||
// see `src/constants.ts` | ||
|
||
// media | ||
declare module '*.mp4' { | ||
const src: string; | ||
export default src; | ||
} | ||
declare module '*.webm' { | ||
const src: string; | ||
export default src; | ||
} | ||
declare module '*.ogg' { | ||
const src: string; | ||
export default src; | ||
} | ||
declare module '*.mp3' { | ||
const src: string; | ||
export default src; | ||
} | ||
declare module '*.wav' { | ||
const src: string; | ||
export default src; | ||
} | ||
declare module '*.flac' { | ||
const src: string; | ||
export default src; | ||
} | ||
declare module '*.aac' { | ||
const src: string; | ||
export default src; | ||
} | ||
|
||
// fonts | ||
declare module '*.woff' { | ||
const src: string; | ||
export default src; | ||
} | ||
declare module '*.woff2' { | ||
const src: string; | ||
export default src; | ||
} | ||
declare module '*.eot' { | ||
const src: string; | ||
export default src; | ||
} | ||
declare module '*.ttf' { | ||
const src: string; | ||
export default src; | ||
} | ||
declare module '*.otf' { | ||
const src: string; | ||
export default src; | ||
} | ||
|
||
// other | ||
declare module '*.wasm' { | ||
const initWasm: (options: WebAssembly.Imports) => Promise<WebAssembly.Exports>; | ||
export default initWasm; | ||
} | ||
declare module '*.webmanifest' { | ||
const src: string; | ||
export default src; | ||
} | ||
declare module '*.pdf' { | ||
const src: string; | ||
export default src; | ||
} | ||
declare module '*.txt' { | ||
const src: string; | ||
export default src; | ||
} | ||
|
||
// web worker | ||
declare module '*?worker' { | ||
const workerConstructor: { | ||
new (): Worker; | ||
}; | ||
export default workerConstructor; | ||
} | ||
|
||
declare module '*?worker&inline' { | ||
const workerConstructor: { | ||
new (): Worker; | ||
}; | ||
export default workerConstructor; | ||
} | ||
|
||
declare module '*?sharedworker' { | ||
const sharedWorkerConstructor: { | ||
new (): SharedWorker; | ||
}; | ||
export default sharedWorkerConstructor; | ||
} | ||
|
||
declare module '*?raw' { | ||
const src: string; | ||
export default src; | ||
} | ||
|
||
declare module '*?url' { | ||
const src: string; | ||
export default src; | ||
} | ||
|
||
declare module '*?inline' { | ||
const src: string; | ||
export default src; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,69 +1,4 @@ | ||
/// <reference types="vite/types/importMeta" /> | ||
|
||
// CSS modules | ||
type CSSModuleClasses = { readonly [key: string]: string }; | ||
|
||
declare module '*.module.css' { | ||
const classes: CSSModuleClasses; | ||
export default classes; | ||
} | ||
declare module '*.module.scss' { | ||
const classes: CSSModuleClasses; | ||
export default classes; | ||
} | ||
declare module '*.module.sass' { | ||
const classes: CSSModuleClasses; | ||
export default classes; | ||
} | ||
declare module '*.module.less' { | ||
const classes: CSSModuleClasses; | ||
export default classes; | ||
} | ||
declare module '*.module.styl' { | ||
const classes: CSSModuleClasses; | ||
export default classes; | ||
} | ||
declare module '*.module.stylus' { | ||
const classes: CSSModuleClasses; | ||
export default classes; | ||
} | ||
declare module '*.module.pcss' { | ||
const classes: CSSModuleClasses; | ||
export default classes; | ||
} | ||
|
||
// CSS | ||
declare module '*.css' { | ||
const css: string; | ||
export default css; | ||
} | ||
declare module '*.scss' { | ||
const css: string; | ||
export default css; | ||
} | ||
declare module '*.sass' { | ||
const css: string; | ||
export default css; | ||
} | ||
declare module '*.less' { | ||
const css: string; | ||
export default css; | ||
} | ||
declare module '*.styl' { | ||
const css: string; | ||
export default css; | ||
} | ||
declare module '*.stylus' { | ||
const css: string; | ||
export default css; | ||
} | ||
declare module '*.pcss' { | ||
const css: string; | ||
export default css; | ||
} | ||
|
||
// Built-in asset types | ||
// see `src/constants.ts` | ||
/// <reference path="./client-base.d.ts" /> | ||
|
||
// images | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Image types are still included here, using |
||
declare module '*.jpg' { | ||
|
@@ -98,110 +33,3 @@ declare module '*.avif' { | |
const src: string; | ||
export default src; | ||
} | ||
|
||
// media | ||
declare module '*.mp4' { | ||
const src: string; | ||
export default src; | ||
} | ||
declare module '*.webm' { | ||
const src: string; | ||
export default src; | ||
} | ||
declare module '*.ogg' { | ||
const src: string; | ||
export default src; | ||
} | ||
declare module '*.mp3' { | ||
const src: string; | ||
export default src; | ||
} | ||
declare module '*.wav' { | ||
const src: string; | ||
export default src; | ||
} | ||
declare module '*.flac' { | ||
const src: string; | ||
export default src; | ||
} | ||
declare module '*.aac' { | ||
const src: string; | ||
export default src; | ||
} | ||
|
||
// fonts | ||
declare module '*.woff' { | ||
const src: string; | ||
export default src; | ||
} | ||
declare module '*.woff2' { | ||
const src: string; | ||
export default src; | ||
} | ||
declare module '*.eot' { | ||
const src: string; | ||
export default src; | ||
} | ||
declare module '*.ttf' { | ||
const src: string; | ||
export default src; | ||
} | ||
declare module '*.otf' { | ||
const src: string; | ||
export default src; | ||
} | ||
|
||
// other | ||
declare module '*.wasm' { | ||
const initWasm: (options: WebAssembly.Imports) => Promise<WebAssembly.Exports>; | ||
export default initWasm; | ||
} | ||
declare module '*.webmanifest' { | ||
const src: string; | ||
export default src; | ||
} | ||
declare module '*.pdf' { | ||
const src: string; | ||
export default src; | ||
} | ||
declare module '*.txt' { | ||
const src: string; | ||
export default src; | ||
} | ||
|
||
// web worker | ||
declare module '*?worker' { | ||
const workerConstructor: { | ||
new (): Worker; | ||
}; | ||
export default workerConstructor; | ||
} | ||
|
||
declare module '*?worker&inline' { | ||
const workerConstructor: { | ||
new (): Worker; | ||
}; | ||
export default workerConstructor; | ||
} | ||
|
||
declare module '*?sharedworker' { | ||
const sharedWorkerConstructor: { | ||
new (): SharedWorker; | ||
}; | ||
export default sharedWorkerConstructor; | ||
} | ||
|
||
declare module '*?raw' { | ||
const src: string; | ||
export default src; | ||
} | ||
|
||
declare module '*?url' { | ||
const src: string; | ||
export default src; | ||
} | ||
|
||
declare module '*?inline' { | ||
const src: string; | ||
export default src; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was the real magic sauce for ESM import types
Moving out all the types except images into a
client-base.d.ts
allows the main use case ofastro/client
to work. The image integration now uses only this base file, avoiding the issue of duplicating*.jpg
module definitions