Skip to content

Commit

Permalink
Revert "chore: update typescript-estree to new package name (#5799)" (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
ikatyang committed Jan 31, 2019
1 parent cb8d300 commit fc93bbc
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 13 deletions.
31 changes: 31 additions & 0 deletions CHANGELOG.unreleased.md
Expand Up @@ -41,3 +41,34 @@ Examples:
```
-->

- TypeScript: Revert "Update typescript-estree to new package name" ([#5818] by [@ikatyang])

There's an internal change introduced in Prettier 1.16.2,
which updated `typescript-estree` to its new package name,
but unfortunately it broke the output
so we reverted it as a temporary workaround for now.

<!-- prettier-ignore -->
```ts
// Input
export default {
load<K, T>(k: K, t: T) {
return {k, t};
}
}

// Output (Prettier 1.16.2)
export default {
load(k: K, t: T) {
return { k, t };
}
};

// Output (Prettier 1.16.3)
export default {
load<K, T>(k: K, t: T) {
return { k, t };
}
};
```
2 changes: 1 addition & 1 deletion docs/options.md
Expand Up @@ -183,7 +183,7 @@ Valid options:
- `"babel"` (via [@babel/parser](https://github.com/babel/babel/tree/master/packages/babel-parser)) _Named `"babylon"` until v1.16.0_
- `"babel-flow"` (Same as `"babel"` but enables Flow parsing explicitly to avoid ambiguity) _First available in v1.16.0_
- `"flow"` (via [flow-parser](https://github.com/facebook/flow/tree/master/src/parser))
- `"typescript"` (via [@typescript-eslint/typescript-estree](https://github.com/typescript-eslint/typescript-eslint)) _First available in v1.4.0_
- `"typescript"` (via [typescript-estree](https://github.com/JamesHenry/typescript-estree)) _First available in v1.4.0_
- `"css"` (via [postcss-scss](https://github.com/postcss/postcss-scss) and [postcss-less](https://github.com/shellscape/postcss-less), autodetects which to use) _First available in v1.7.1_
- `"scss"` (same parsers as `"css"`, prefers postcss-scss) _First available in v1.7.1_
- `"less"` (same parsers as `"css"`, prefers postcss-less) _First available in v1.7.1_
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -19,7 +19,6 @@
"@babel/parser": "7.2.0",
"@glimmer/syntax": "0.30.3",
"@iarna/toml": "2.0.0",
"@typescript-eslint/typescript-estree": "1.1.0",
"angular-estree-parser": "1.1.5",
"angular-html-parser": "1.2.0",
"camelcase": "4.1.0",
Expand Down Expand Up @@ -68,6 +67,7 @@
"semver": "5.4.1",
"string-width": "3.0.0",
"typescript": "3.2.2",
"typescript-estree": "18.0.0",
"unicode-regex": "2.0.0",
"unified": "6.1.6",
"vnopts": "1.0.2",
Expand Down
2 changes: 1 addition & 1 deletion scripts/build/config.js
Expand Up @@ -39,7 +39,7 @@ const parsers = [
input: "src/language-js/parser-typescript.js",
target: "universal",
replace: {
// node v4 compatibility for @typescript-eslint/typescript-estree
// node v4 compatibility for typescript-estree
"(!unique.includes(raw))": "(unique.indexOf(raw) === -1)"
}
},
Expand Down
2 changes: 2 additions & 0 deletions src/language-js/needs-parens.js
Expand Up @@ -308,6 +308,7 @@ function needsParens(path, options) {

case "ClassExpression":
case "ClassDeclaration":
case "TSAbstractClassDeclaration":
return name === "superClass" && parent.superClass === node;
case "TSTypeAssertion":
case "TaggedTemplateExpression":
Expand Down Expand Up @@ -744,6 +745,7 @@ function isStatement(node) {
node.type === "SwitchStatement" ||
node.type === "ThrowStatement" ||
node.type === "TryStatement" ||
node.type === "TSAbstractClassDeclaration" ||
node.type === "TSDeclareFunction" ||
node.type === "TSEnumDeclaration" ||
node.type === "TSImportEqualsDeclaration" ||
Expand Down
2 changes: 1 addition & 1 deletion src/language-js/parser-typescript.js
Expand Up @@ -36,7 +36,7 @@ function parse(text, parsers, opts) {
}

function tryParseTypeScript(text, jsx) {
const parser = require("@typescript-eslint/typescript-estree");
const parser = require("typescript-estree");
return parser.parse(text, {
loc: true,
range: true,
Expand Down
4 changes: 3 additions & 1 deletion src/language-js/printer-estree.js
Expand Up @@ -2346,6 +2346,7 @@ function printPathNoParens(path, options, print, args) {
}
case "ClassDeclaration":
case "ClassExpression":
case "TSAbstractClassDeclaration":
if (isNodeStartingWithDeclare(n, options)) {
parts.push("declare ");
}
Expand Down Expand Up @@ -4358,6 +4359,7 @@ function printExportDeclaration(path, options, print) {
isDefault &&
(decl.declaration.type !== "ClassDeclaration" &&
decl.declaration.type !== "FunctionDeclaration" &&
decl.declaration.type !== "TSAbstractClassDeclaration" &&
decl.declaration.type !== "TSInterfaceDeclaration" &&
decl.declaration.type !== "DeclareClass" &&
decl.declaration.type !== "DeclareFunction" &&
Expand Down Expand Up @@ -4524,7 +4526,7 @@ function printClass(path, options, print) {
const n = path.getValue();
const parts = [];

if (n.abstract) {
if (n.type === "TSAbstractClassDeclaration") {
parts.push("abstract ");
}

Expand Down
16 changes: 8 additions & 8 deletions yarn.lock
Expand Up @@ -674,14 +674,6 @@
version "5.5.0"
resolved "https://registry.yarnpkg.com/@types/semver/-/semver-5.5.0.tgz#146c2a29ee7d3bae4bf2fcb274636e264c813c45"

"@typescript-eslint/typescript-estree@1.1.0":
version "1.1.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-1.1.0.tgz#31f19e7197814cb3e609f2822ad6003b6e326470"
integrity sha512-eABnKqJVv0Mm5uYon8Xw61SXldvOhWKDQdoZqsJ/YqEa9XvWV1URXdRvTOW8GLsKo4X3Un7pHKqKZhfbbUEGww==
dependencies:
lodash.unescape "4.0.1"
semver "5.5.0"

abab@^1.0.4:
version "1.0.4"
resolved "https://registry.yarnpkg.com/abab/-/abab-1.0.4.tgz#5faad9c2c07f60dd76770f71cf025b62a63cfd4e"
Expand Down Expand Up @@ -5784,6 +5776,14 @@ typedarray@^0.0.6:
version "0.0.6"
resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777"

typescript-estree@18.0.0:
version "18.0.0"
resolved "https://registry.yarnpkg.com/typescript-estree/-/typescript-estree-18.0.0.tgz#a309f6c6502c64d74b3f88c205d871a9af0b1d40"
integrity sha512-HxTWrzFyYOPWA91Ij7xL9mNUVpGTKLH2KiaBn28CMbYgX2zgWdJqU9hO7Are+pAPAqY91NxAYoaAyDDZ3rLj2A==
dependencies:
lodash.unescape "4.0.1"
semver "5.5.0"

typescript@3.2.2:
version "3.2.2"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.2.2.tgz#fe8101c46aa123f8353523ebdcf5730c2ae493e5"
Expand Down

0 comments on commit fc93bbc

Please sign in to comment.