Skip to content

Commit

Permalink
[dev-tool] upgrade dev dependency typescript to ~4.8.0 (#23244)
Browse files Browse the repository at this point in the history
and react to the changes that decorators are now in the same field as
modifiers

https://devblogs.microsoft.com/typescript/announcing-typescript-4-8/#decorators-are-placed-on-modifiers-on-typescripts-syntax-trees

* upgrade eslint-plugin too
  • Loading branch information
jeremymeng authored Sep 19, 2022
1 parent 3e56b5b commit ef40dc3
Show file tree
Hide file tree
Showing 9 changed files with 62 additions and 65 deletions.
68 changes: 34 additions & 34 deletions common/config/rush/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion common/tools/dev-tool/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"prettier": "^2.4.1",
"ts-node": "^10.0.0",
"tslib": "^2.2.0",
"typescript": "~4.6.0",
"typescript": "~4.8.0",
"yaml": "~1.10.0"
},
"devDependencies": {
Expand Down
5 changes: 1 addition & 4 deletions common/tools/dev-tool/src/util/samples/processor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,6 @@ function processExportDefault(
// If there is no name, the declaration is anonymous, and we will bind it as an expression in module.exports
const initializer = ts.isClassDeclaration(decl)
? factory.createClassExpression(
decl.decorators,
updatedModifiers,
undefined,
decl.typeParameters,
Expand All @@ -340,7 +339,7 @@ function processExportDefault(
: decl.body === undefined // This is a strange case that I assume has to do with overload declarations.
? undefined
: factory.createFunctionExpression(
updatedModifiers,
updatedModifiers as readonly ts.Modifier[], // it's not legal to decorate function expressions so these should all be modifiers.
decl.asteriskToken,
undefined,
decl.typeParameters,
Expand All @@ -361,7 +360,6 @@ function processExportDefault(
return ts.isClassDeclaration(decl)
? factory.updateClassDeclaration(
decl,
decl.decorators,
updatedModifiers,
decl.name,
decl.typeParameters,
Expand All @@ -370,7 +368,6 @@ function processExportDefault(
)
: factory.updateFunctionDeclaration(
decl,
decl.decorators,
updatedModifiers,
decl.asteriskToken,
decl.name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
},
"devDependencies": {
"@types/node": "^12.0.0",
"typescript": "~4.6.0",
"typescript": "~4.8.0",
"rimraf": "latest"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
},
"devDependencies": {
"@types/node": "^12.0.0",
"typescript": "~4.6.0",
"typescript": "~4.8.0",
"rimraf": "latest"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
},
"devDependencies": {
"@types/node": "^12.0.0",
"typescript": "~4.6.0",
"typescript": "~4.8.0",
"rimraf": "latest"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
},
"devDependencies": {
"@types/node": "^12.0.0",
"typescript": "~4.6.0",
"typescript": "~4.8.0",
"rimraf": "latest"
}
}
4 changes: 2 additions & 2 deletions common/tools/eslint-plugin-azure-sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
"eslint-config-prettier": "^8.0.0",
"glob": "^8.0.0",
"json-schema": "^0.4.0",
"typescript": "~4.6.0",
"typescript": "~4.8.0",
"tslib": "^2.2.0"
},
"devDependencies": {
Expand All @@ -93,7 +93,7 @@
"rimraf": "^3.0.0",
"source-map-support": "^0.5.9",
"mocha-junit-reporter": "^2.0.0",
"typescript": "~4.6.0",
"typescript": "~4.8.0",
"eslint-plugin-markdown": "~3.0.0"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import {
Declaration,
Modifier,
ModifierLike,
PropertySignature,
SymbolFlags,
SyntaxKind,
Expand Down Expand Up @@ -274,7 +275,8 @@ export = {
if (
modifiers !== undefined &&
modifiers.some(
(modifier: Modifier): boolean => modifier.kind === SyntaxKind.PrivateKeyword
(modifier: Modifier | ModifierLike): boolean =>
modifier.kind === SyntaxKind.PrivateKeyword
)
) {
return;
Expand All @@ -286,18 +288,17 @@ export = {
const symbol = typeChecker
.getTypeAtLocation(converter.get(node as TSESTree.Node))
.getSymbol();
const overloads =
symbol?.declarations
? symbol.declarations
.filter(
(declaration: Declaration): boolean =>
reverter.get(declaration as TSNode) !== undefined
)
.map((declaration: Declaration): FunctionExpression => {
const method = reverter.get(declaration as TSNode) as MethodDefinition;
return method.value;
})
: [];
const overloads = symbol?.declarations
? symbol.declarations
.filter(
(declaration: Declaration): boolean =>
reverter.get(declaration as TSNode) !== undefined
)
.map((declaration: Declaration): FunctionExpression => {
const method = reverter.get(declaration as TSNode) as MethodDefinition;
return method.value;
})
: [];
evaluateOverloads(
overloads,
converter,
Expand Down Expand Up @@ -326,13 +327,12 @@ export = {
const symbol = typeChecker
.getTypeAtLocation(converter.get(node as TSESTree.Node))
.getSymbol();
const overloads =
symbol?.declarations
? symbol.declarations.map(
(declaration: Declaration): FunctionDeclaration =>
reverter.get(declaration as TSNode) as FunctionDeclaration
)
: [];
const overloads = symbol?.declarations
? symbol.declarations.map(
(declaration: Declaration): FunctionDeclaration =>
reverter.get(declaration as TSNode) as FunctionDeclaration
)
: [];
evaluateOverloads(
overloads,
converter,
Expand Down

0 comments on commit ef40dc3

Please sign in to comment.