-
Notifications
You must be signed in to change notification settings - Fork 808
feat(typescript): update to typescript 4.3.5 #3103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
02a06ee
ad2c239
308d16b
e17ec84
f71caa2
a8d30d6
aa39cb1
8404abd
98bfd96
d0ab630
aedcc28
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,41 @@ | ||||||||
import { mapJSDocTagInfo } from '../transform-utils'; | ||||||||
|
||||||||
describe('transform utils', () => { | ||||||||
it('flattens TypeScript JSDocTagInfo to Stencil JSDocTagInfo', () => { | ||||||||
// tags corresponds to the following JSDoc | ||||||||
/* | ||||||||
* @param foo the first parameter | ||||||||
* @param bar | ||||||||
* @returns | ||||||||
* @see {@link https://example.com} | ||||||||
*/ | ||||||||
const tags = [ | ||||||||
{ | ||||||||
name: 'param', | ||||||||
text: [ | ||||||||
{ text: 'foo', kind: 'parameterName' }, | ||||||||
{ text: ' ', kind: 'space' }, | ||||||||
{ text: 'the first parameter', kind: 'text' }, | ||||||||
], | ||||||||
}, | ||||||||
{ name: 'param', text: [{ text: 'bar', kind: 'text' }] }, | ||||||||
{ name: 'returns', text: undefined }, | ||||||||
{ | ||||||||
name: 'see', | ||||||||
text: [ | ||||||||
{ text: '', kind: 'text' }, | ||||||||
{ text: '{@link ', kind: 'link' }, | ||||||||
{ text: 'https://example.com', kind: 'linkText' }, | ||||||||
{ text: '}', kind: 'link' }, | ||||||||
], | ||||||||
}, | ||||||||
]; | ||||||||
|
||||||||
expect(mapJSDocTagInfo(tags)).toEqual([ | ||||||||
{ name: 'param', text: 'foo the first parameter' }, | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To coincide with my suggestion above:
Suggested change
|
||||||||
{ name: 'param', text: 'bar' }, | ||||||||
{ name: 'returns', text: undefined }, | ||||||||
{ name: 'see', text: '{@link https://example.com}' }, | ||||||||
]); | ||||||||
}); | ||||||||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -515,11 +515,23 @@ export const serializeSymbol = (checker: ts.TypeChecker, symbol: ts.Symbol): d.C | |
}; | ||
} | ||
return { | ||
tags: symbol.getJsDocTags().map((tag) => ({ text: tag.text, name: tag.name })), | ||
tags: mapJSDocTagInfo(symbol.getJsDocTags()), | ||
text: ts.displayPartsToString(symbol.getDocumentationComment(checker)), | ||
}; | ||
}; | ||
|
||
/** | ||
* Maps a TypeScript 4.3+ JSDocTagInfo to a flattened Stencil CompilerJsDocTagInfo. | ||
* @param tags A readonly array of JSDocTagInfo objects. | ||
* @returns An array of CompilerJsDocTagInfo objects. | ||
*/ | ||
export const mapJSDocTagInfo = (tags: readonly ts.JSDocTagInfo[]): d.CompilerJsDocTagInfo[] => { | ||
// The text following a tag is split semantically by TS 4.3+, e.g. '@param foo the first parameter' -> | ||
// [{text: 'foo', kind: 'parameterName'}, {text: ' ', kind: 'space'}, {text: 'the first parameter', kind: 'text'}], so | ||
// we join the elements to reconstruct the text. | ||
return tags.map((tag) => ({ ...tag, text: tag.text?.map((part) => part.text).join('') })); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When we have >1 /**
* The middle name
* @argument i love to argue
* @async nsync backstreet boys
*/
@Prop() middle: string; Which internally becomes:
When we create a JSON readme, this all looks right to me: {
"name": "middle",
"type": "string",
"mutable": false,
"attr": "middle",
"reflectToAttr": false,
"docs": "The middle name",
"docsTags": [
{
"name": "argument",
"text": "i love to argue"
},
{
"name": "async",
"text": "nsync backstreet boys"
}
],
"values": [
{
"type": "string"
}
],
"optional": false,
"required": false
}
], Is my understanding right there? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Exactly. I've added a comment describing this. |
||
}; | ||
|
||
export const serializeDocsSymbol = (checker: ts.TypeChecker, symbol: ts.Symbol) => { | ||
const type = checker.getTypeOfSymbolAtLocation(symbol, symbol.valueDeclaration); | ||
const set = new Set<string>(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Can we add a test for no/empty text?