You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(compiler): fix typedef file generated for dist-custom-elements (#3468)
This fixes the typedef file generated for the `index.js` file produced
by `dist-custom-elements`. Previously it was mistakenly assuming that
the path to a component's `d.ts` file could be generated on the basis of
the `tag` set on the component. This _is_ the case if the component's
filename is equal to it's tag, but there is no requirement that that be
the case.
This changes the way that the relative path from
`${outputDir}/components/index.d.ts` to the `.d.ts` file for a specific
component is generated.
Previously we were doing something like:
```ts
${outputDir}/types/components/${component.tagName}/${component.tagName}
```
This doesn't work if a component is saved in
`src/components/button/button.tsx` but has a tag like `custom-button`.
So to fix this we can instead:
- find the relative path from the source root to the component, giving
us e.g. `components/button/button.tsx`
- join that relative path with the relative path from where `index.d.ts`
is going to be saved (`${outputDir}/components/index.d.ts`) to the
directory where types are written (e.g. `${outputDir}/types`)
This will give us an import in `index.d.ts` that looks like:
```ts
export { Button as CustomButton } from '../types/components/button/button.tsx';
```
0 commit comments