Commit graph

100 commits

Author SHA1 Message Date
Brian Donovan
9bddaef3e5
style: fix formatting 2025-03-02 17:52:04 -08:00
Brian Donovan
23af4519a2
Merge pull request #1415 from spanishpear/master
Feat: support Typescript type arguments on tagged template literals
2025-03-02 17:45:33 -08:00
ssomaiya
539b8d3230
Feat: support Typescript type arguments on tagged template literals 2024-11-25 22:17:40 +11:00
tim
2d6919c889 fixes incorrect indentation that could happen with tabs 2024-07-16 23:33:57 +02:00
tim
897a70a8ba fixes formatting 2024-06-18 18:57:29 +02:00
tim
2bfb82f24a fixes double parentheses for JSXFragments too 2024-06-18 08:21:05 +02:00
tim
91896cfcfc avoids double-parentheses on JSXElements 2024-06-18 07:40:40 +02:00
Brian Donovan
5d0ec0a563
fix: prevent removal of trailing JSX whitespace
This just re-applies the fix from #1223 by @coderaiser on top of `master`.
2024-06-01 18:08:35 +00:00
Brian Donovan
6f7466ea8e
Merge pull request #1383 from dandean/patch-1 2024-05-31 07:43:54 -07:00
Brian Donovan
b36db43e8d
style: reformat with prettier 2024-05-31 14:34:27 +00:00
Parth Mane
dd8cea468e chore: Support type parameters on JSX components in TSX (<Foo<Bar> />) 2024-04-08 13:02:00 +05:30
Brian Donovan
bc87a950bb
fix: print export namespace specifiers without braces
Fixes #1390
2024-03-03 11:46:01 -08:00
43081j
ed236b84d6 chore: run format 2024-03-02 12:27:04 +00:00
Brian Donovan
efaae58d3d
refactor: replace assert with tiny-invariant 2024-03-01 15:27:32 -08:00
Dan Dean
f0f50943d8
Update printer.ts to support kind = 'get'/'set' on TSMethodSignature
`TSMethodSignature` has a `kind` property which can be set to `method` (the default), `get`, and `set`. When `get` and `set`, the method is a getter or a setter, and as such, should be prefixed with either `get ` or `set `.
2024-01-02 17:22:54 -08:00
Ash Searle
9292af1162 fix: print ExportSpecifier.exportKind 2023-07-05 21:56:37 +01:00
Brian Donovan
63d5431f9a ensure class member modifiers are printed correctly 2022-12-14 08:28:07 -08:00
Brian Donovan
780487577a Implement pretty-printer case for ClassAccessorProperty.
It's very similar to the one from Babel: f5b52208f0/packages/babel-generator/src/generators/classes.ts (L123-L166). However, `ast-types` doesn't seem to think a `definite` attribute exists on this node type so the type checking fails.
2022-12-13 07:49:05 -08:00
Ben Newman
e51e1bfe49
Implement pretty-printer case for TSSatisfiesExpression.
The printer for the `TSSatisfiesExpression` type is almost identical to
the one for `TSAsExpression`, according to this implementation by Babel:
f5b52208f0/packages/babel-generator/src/generators/typescript.ts (L525-L541)
2022-12-11 15:37:42 -05:00
Ben Newman
e1bc08d78d
Implement pretty-printer case for TSTypeCastExpression.
I'm basing this implementation on the following old Babel printer case:
b84f4f2d69/packages/babel-generator/src/generators/typescript.js (L376-L379)

Since I can't find `TSTypeCastExpression` anywhere in the Babel codebase
these days, it might not be used in the wild any longer, but it doesn't
hurt to have a printer case for it, just in case it pops up.
2022-12-11 15:23:42 -05:00
Brian Donovan
413d600a0a
feat(ts): add support for TSInstantiationExpression
Refs #1230

See https://devblogs.microsoft.com/typescript/announcing-typescript-4-7-beta/#instantiation-expressions.

This won't work yet because `ast-types` does not yet know about
`TSInstantiationExpression`. Once it does `recast` will need to be
updated to include the newer release of `ast-types`, at which point it
will be supported.
2022-12-11 15:05:14 -05:00
Ben Newman
f76948ecca
Pretty-print semicolons after TSInterfaceBody elements, too. 2022-12-10 18:01:18 -05:00
Ben Newman
1ac55c88e9
Use semicolons in TSTypeLiteral again (not commas though).
Follow-up to PR #1157 that I caught while trying to regenerate the
TypeScript declarations for ast-types, and noticed a bunch of (IMHO
reasonable) semicolons going missing.
2022-12-10 17:46:01 -05:00
Greg Price
7891bc75c3 Unify DeclareClass with ClassDeclaration
These have so much in common that when they're implemented separately,
it's easy (as the breakage fixed in the previous commit demonstrates)
for one of them to lag behind in getting a feature the other has.
2022-09-27 05:36:14 +00:00
Greg Price
d0a1729f3a Support Flow "declare class" fully: type parameters, "extends", "implements".
This is basically copied from the "ClassDeclaration" case.
There's so much in common between them -- it'd be nice to share
most of this logic.
2022-09-27 05:36:14 +00:00
Brian Donovan
295d7c8028
Merge pull request #1151 from 625dennis/fix-typescript-override-keyword-printer
Fix typescript override keyword printer
2022-09-26 22:23:20 -07:00
coderaiser
fbab80418f fix: print options: quote 2022-09-27 03:26:27 +00:00
hdineen
165e92a297 fix: additional commas in TsTypeLiteral 2022-08-03 10:16:51 -07:00
Dennis Kuduzovic
bc030e5530 add override keyword to printMethod function 2022-07-19 21:34:32 -06:00
Lily Scott
aec4d901fa Fix #1146 2022-07-12 17:33:05 -06:00
Georgii Dolzhykov
ba51321748 Reformat all 2022-04-27 23:03:05 +00:00
Brian Donovan
06eca93f28
Merge pull request #1013 from lokshunhung/fix/ts-class-prop-definite
Print class property definite assignment assertions
2022-04-27 15:56:37 -07:00
LS Hung
e71ab9bc6a Test printing definite class property 2022-04-27 22:53:58 +00:00
coderaiser
6e0685ceb1 fix: additional semicolon in TSInterfaceBody 2022-04-27 22:40:08 +00:00
Conrad Buck
eb94a84167 Fix missing parens in reprinted output 2022-04-26 08:49:45 -04:00
Devin J. Pohly
7767878ff9 Fix pretty-printing strings with \u2028 or \u2029
These two characters are considered ordinary characters by JSON but line
terminators by ECMAScript (prior to ES2019).  When pretty-printing a
string containing either character, JSON.stringify leaves it unescaped.
The result in recast.prettyPrint is that fromString, which follows
ECMAScript definitions, converts it mistakenly to a newline character.

Escaping these characters manually when the intent is to generate
ECMAScript (rather than JSON) eliminates the problem.
2022-02-03 14:28:04 -06:00
Ben Newman
abacfa70c3
Allow pretty-printing TopicReference AST nodes.
https://github.com/babel/babel/pull/13191
2021-12-02 15:12:45 -05:00
Ben Newman
9a55bb1bc0
Allow pretty-printing V8IntrinsicIdentifier AST nodes.
https://github.com/babel/babel/pull/10148
2021-12-02 15:12:44 -05:00
Ben Newman
ab5b87d3fb
Allow pretty-printing DecimalLiteral AST nodes. 2021-12-02 15:12:44 -05:00
Ben Newman
8e542935d0
Regularize printing of node.extra for Literal subtypes. 2021-12-02 15:12:44 -05:00
Ben Newman
01a532cd4d
Allow pretty-printing TSIntrinsicKeyword AST nodes. 2021-12-02 15:12:44 -05:00
Ben Newman
15f91e24fe
Allow pretty-printing Flow [Optional]IndexedAccessType AST nodes. 2021-12-02 15:12:44 -05:00
Ben Newman
a52c62d779
Allow pretty-printing ModuleExpression AST nodes. 2021-12-02 15:12:44 -05:00
Ben Newman
066138caad
Allow pretty-printing {Record,Tuple}Expression AST nodes.
I chose not to support the `{|...|}` and `[|...|]` syntax, in favor of
`#{...}` and `#[...]`, since that's where TC39 seems to be headed (and
it's shorter and easier to print): https://github.com/tc39/proposal-record-tuple/issues/10
2021-12-02 15:12:44 -05:00
Ben Newman
8f1bcee915
Allow pretty-printing ImportAttribute AST nodes.
Like https://github.com/babel/babel/pull/11641, but updated to reflect
the current AST spec: https://github.com/babel/babel/blob/main/packages/babel-parser/ast/spec.md#imports
2021-12-02 15:12:44 -05:00
Ben Newman
dbf2d78e93
Allow pretty-printing StaticBlock AST nodes. 2021-12-02 15:12:44 -05:00
Oskari Noppa
d8946c6a03
Print Flow FunctionTypeAnnotation.typeParameters (#961)
Fixes #960
2021-07-22 16:39:52 -04:00
Ben Newman
21072427a0
Add more tests of chain expressions. (#783)
Follow-up to #766.
2020-10-12 13:55:53 -04:00
Ethan Crook
fe870fd2c3 Removed semicolon from ChainExpression printer 2020-09-21 17:53:12 -06:00
Ethan Crook
f3bfef4919 Added ChainExpression/ChainElement to printer.ts 2020-09-21 09:47:23 -06:00