rsnext/packages/next/font/index.d.ts
Hannes Bornö 6ab52ed41b
@next/font return types (#42753)
Currently the return type is the same when you declare a variable and
when you don't.
```tsx
const inter1 = Inter()
const inter2 = Inter({ variable: "--inter-font" })

inter1.variable // string | undefined
inter2.variable // string | undefined
```

With this change you get a type error if you try to access `.variable`
without providing a variable name.
```tsx
const inter1 = Inter()
const inter2 = Inter({ variable: "--inter-font" })

inter1.variable // Property 'variable' does not exist on type 'NextFont'.ts(2339)
inter2.variable // string
```

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have a helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the
feature request has been accepted for implementation before opening a
PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have a helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm build && pnpm lint`
- [ ] The "examples guidelines" are followed from [our contributing
doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
2022-11-10 08:56:27 -08:00

26 lines
599 B
TypeScript

export type AdjustFontFallback = {
fallbackFont: string
ascentOverride?: string
descentOverride?: string
lineGapOverride?: string
sizeAdjust?: string
}
export type FontLoader = (options: {
functionName: string
variableName: string
data: any[]
config: any
emitFontFile: (content: Buffer, ext: string, preload: boolean) => string
resolve: (src: string) => string
isDev: boolean
isServer: boolean
loaderContext: any
}) => Promise<{
css: string
fallbackFonts?: string[]
variable?: string
adjustFontFallback?: AdjustFontFallback
weight?: string
style?: string
}>