Closed colinrotherham closed 1 year ago
Thanks for working on this. Can it be done by adding a .d.ts
file?
Thanks for working on this. Can it be done by adding a
.d.ts
file?
Yeah course, I've pushed up a new .gitignore to show them:
index.d.cts
type declarations for .cjs
extension filesindex.d.cts.map
type declaration map to link back to sourceDeclaration Map Generates a source map for
.d.ts
files which map back to the original.ts
source file. This will allow editors such as VS Code to go to the original.ts
file when using features like Go to Definition.
I've used import('prettier')
in the JSDoc to make sure the existing type declarations are reused when built
I have no experience with type declarations.
@SimenB Can you help review?
@fisker I've removed all the unnecessary autogenerated lines from index.d.cts
We're left with the good stuff like Awaited<ReturnType<Prettier[FunctionName]>>
But I've kept the tsconfig.json and JSDoc comments so you get type checking locally too
Thank you @colinrotherham
Released https://github.com/prettier/prettier-synchronized/releases/tag/v0.3.0
Brilliant, thanks @fisker
Just a reminder that manually adding the types without a type declaration map means editor and IDE "Go to definition" will jump to the types rather than the original Prettier source code, should you want that in future
Glad I could help though, appreciate it
Great work on Prettier v3 🙌
Hope this PR is welcome, but I've added JSDoc + tsconfig.json to export type declarations
I followed the link in the Prettier 3.0: Hello, ECMAScript Modules! blog post after realising that the Prettier sync APIs would still be needed to avoid Nunjucks template changes for asynchronous rendering 😣
I'd be happy to make any tweaks, and wasn't sure if committing the types would be preferred
Closes: https://github.com/prettier/prettier-synchronized/issues/8