[ci] yarn format
This commit is contained in:
parent
a136c85e6b
commit
d8a162aeee
3 changed files with 10 additions and 7 deletions
|
@ -6,7 +6,6 @@
|
|||
|
||||
Astro props are now accessed from the `Astro.props` global. This change is meant to make prop definitions more ergonomic, leaning into JavaScript patterns you already know (destructuring and defaults). Astro components previously used a prop syntax borrowed from [Svelte](https://svelte.dev/docs#1_export_creates_a_component_prop), but it became clear that this was pretty confusing for most users.
|
||||
|
||||
|
||||
```diff
|
||||
---
|
||||
+ const { text = 'Hello world!' } = Astro.props;
|
||||
|
@ -60,4 +59,3 @@ const { text = 'Hello world!' } = Astro.props;
|
|||
if (typeof text !== 'string') throw new Error(`Expected "text" to be of type "string" but recieved "${typeof string}"!`);
|
||||
---
|
||||
```
|
||||
|
||||
|
|
|
@ -99,6 +99,7 @@ const { greeting = 'Hello', name } = Astro.props;
|
|||
```
|
||||
|
||||
To define the props which your component accepts, you may export a TypeScript interface or type named `Props`.
|
||||
|
||||
```tsx
|
||||
---
|
||||
export interface Props {
|
||||
|
|
|
@ -386,12 +386,16 @@ function compileModule(module: Script, state: CodegenState, compileOptions: Comp
|
|||
|
||||
if (componentProps.length > 0) {
|
||||
const shortname = path.posix.relative(compileOptions.astroConfig.projectRoot.pathname, state.filename);
|
||||
const props = componentProps.map(prop => (prop.id as Identifier)?.name).filter(v => v);
|
||||
const props = componentProps.map((prop) => (prop.id as Identifier)?.name).filter((v) => v);
|
||||
console.log();
|
||||
warn(compileOptions.logging, shortname, yellow(`\nDefining props with "export" has been removed! Please see https://github.com/snowpackjs/astro/blob/main/packages/astro/CHANGELOG.md#0150
|
||||
warn(
|
||||
compileOptions.logging,
|
||||
shortname,
|
||||
yellow(`\nDefining props with "export" has been removed! Please see https://github.com/snowpackjs/astro/blob/main/packages/astro/CHANGELOG.md#0150
|
||||
Please update your code to use:
|
||||
|
||||
const { ${props.join(', ')} } = Astro.props;\n`));
|
||||
const { ${props.join(', ')} } = Astro.props;\n`)
|
||||
);
|
||||
}
|
||||
|
||||
// handle createCollection, if any
|
||||
|
|
Loading…
Reference in a new issue