Support TypeScript 4.1 via typescript-estree (#9636)
* Update typescript and typescript-estree * Add AST transformation for TSTemplateLiteralType * Update tests for template-literal-types * Fix transformChainExpression * Update tests for key-remapping-in-mapped-types * Implement recoverInvalidDecorators * Update changelog * Avoid typecheck error * Add os.platform() shim * Update config.js * Update config.js * Shim os.cpus * Update `process.versions.node` * Attempt to fix build * Update ts parserOptions * Fix code style * Remove `errorOnUnknownASTType`, fix code style * Use `[] ||` instead of `[] //` * Fix hack * Add invalid tests * checkMissingDecorators * Update tests * Fix tests * Add comment * Revert "Implement recoverInvalidDecorators" This reverts commit 27e7b46ed41df36fb585791117c85e1b2dab932c. * Add ref pr link * Simplify logic * Don't transform `TSTemplateLiteralType` * Add `TSTemplateLiteralType` as simple type * Fix tests * Update comments * Add comment * Fix logic * Minor tweak * use multiple parsers * Update @typescript-eslint/typescript-estree to v4.8.0 * Switch to `parseWithNodeMaps` * Rename `esNode` -> `esTreeNode` * Update @typescript-eslint/typescript-estree to 4.8.1-alpha.1 * Use @typescript-eslint/typescript-estree 4.8.1 Co-authored-by: fisker Cheung <lionkay@gmail.com>
This commit is contained in:
1 parent
702f543635
commit
4cc149248a
32 files changed
+304
-168
No files matched your search
@@ -1,6 +1,4 @@
|
||||
#### [HIGHLIGHT]Support TypeScript 4.1 via Babel (#9473 by @sosukesuzuki)
|
||||
|
||||
`--parser=babel-ts` is required.
|
||||
#### [HIGHLIGHT]Support TypeScript 4.1 (#9473, #9636 by @sosukesuzuki)
|
||||
|
||||
##### Key Remapping In Mapped Types
|
||||
|
||||
|
||||
+2
-2
@@ -25,7 +25,7 @@
|
||||
"@babel/parser": "7.12.5",
|
||||
"@glimmer/syntax": "0.66.0",
|
||||
"@iarna/toml": "2.2.5",
|
||||
"@typescript-eslint/typescript-estree": "3.10.1",
|
||||
"@typescript-eslint/typescript-estree": "4.8.1",
|
||||
"angular-estree-parser": "2.2.1",
|
||||
"angular-html-parser": "1.7.1",
|
||||
"camelcase": "6.2.0",
|
||||
@@ -78,7 +78,7 @@
|
||||
"resolve": "1.19.0",
|
||||
"semver": "7.3.2",
|
||||
"string-width": "4.2.0",
|
||||
"typescript": "4.0.5",
|
||||
"typescript": "4.1.1-rc",
|
||||
"unicode-regex": "3.0.0",
|
||||
"unified": "9.2.0",
|
||||
"vnopts": "1.0.2",
|
||||
|
||||
@@ -40,6 +40,11 @@ const parsers = [
|
||||
// `TypeScript`, `toolsVersion`, `globalThis`
|
||||
'typeof process === "undefined" || process.browser': "false",
|
||||
'typeof globalThis === "object"': "true",
|
||||
// `@typescript-eslint/typescript-estree` v4
|
||||
'require("globby")': "{}",
|
||||
"extra.projects = prepareAndTransformProjects(":
|
||||
"extra.projects = [] || prepareAndTransformProjects(",
|
||||
"process.versions.node": "'999.999.999'",
|
||||
},
|
||||
},
|
||||
{
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
export default {
|
||||
EOL: "\n",
|
||||
platform: () => "browser",
|
||||
cpus: () => [{ model: "Prettier" }],
|
||||
};
|
||||
@@ -1,15 +1,8 @@
|
||||
"use strict";
|
||||
|
||||
const {
|
||||
concat,
|
||||
join,
|
||||
hardline,
|
||||
line,
|
||||
softline,
|
||||
group,
|
||||
indent,
|
||||
ifBreak,
|
||||
} = require("../document").builders;
|
||||
builders: { concat, join, hardline, line, softline, group, indent, ifBreak },
|
||||
} = require("../document");
|
||||
const { isNextLineEmpty } = require("../common/util");
|
||||
const { insertPragma } = require("./pragma");
|
||||
const { locStart, locEnd } = require("./loc");
|
||||
|
||||
@@ -1,15 +1,8 @@
|
||||
"use strict";
|
||||
|
||||
const {
|
||||
concat,
|
||||
group,
|
||||
hardline,
|
||||
ifBreak,
|
||||
indent,
|
||||
join,
|
||||
line,
|
||||
softline,
|
||||
} = require("../document").builders;
|
||||
builders: { concat, group, hardline, ifBreak, indent, join, line, softline },
|
||||
} = require("../document");
|
||||
const { locStart, locEnd } = require("./loc");
|
||||
const clean = require("./clean");
|
||||
const {
|
||||
|
||||
@@ -5,6 +5,7 @@ const {
|
||||
getNextNonSpaceNonCommentCharacter,
|
||||
getShebang,
|
||||
} = require("../common/util");
|
||||
const createError = require("../common/parser-create-error");
|
||||
const { composeLoc, locStart, locEnd } = require("./loc");
|
||||
const { isTypeCastComment } = require("./comments");
|
||||
|
||||
@@ -17,6 +18,50 @@ function postprocess(ast, options) {
|
||||
includeShebang(ast, options);
|
||||
}
|
||||
|
||||
// Invalid decorators are removed since `@typescript-eslint/typescript-estree` v4
|
||||
// https://github.com/typescript-eslint/typescript-eslint/pull/2375
|
||||
if (options.parser === "typescript" && options.originalText.includes("@")) {
|
||||
const {
|
||||
esTreeNodeToTSNodeMap,
|
||||
tsNodeToESTreeNodeMap,
|
||||
} = options.tsParseResult;
|
||||
ast = visitNode(ast, (node) => {
|
||||
const tsNode = esTreeNodeToTSNodeMap.get(node);
|
||||
if (!tsNode) {
|
||||
return;
|
||||
}
|
||||
const tsDecorators = tsNode.decorators;
|
||||
if (!Array.isArray(tsDecorators)) {
|
||||
return;
|
||||
}
|
||||
// `esTreeNodeToTSNodeMap.get(ClassBody)` and `esTreeNodeToTSNodeMap.get(ClassDeclaration)` has the same tsNode
|
||||
const esTreeNode = tsNodeToESTreeNodeMap.get(tsNode);
|
||||
if (esTreeNode !== node) {
|
||||
return;
|
||||
}
|
||||
const esTreeDecorators = esTreeNode.decorators;
|
||||
if (
|
||||
!Array.isArray(esTreeDecorators) ||
|
||||
esTreeDecorators.length !== tsDecorators.length ||
|
||||
tsDecorators.some((tsDecorator) => {
|
||||
const esTreeDecorator = tsNodeToESTreeNodeMap.get(tsDecorator);
|
||||
return (
|
||||
!esTreeDecorator || !esTreeDecorators.includes(esTreeDecorator)
|
||||
);
|
||||
})
|
||||
) {
|
||||
const { start, end } = esTreeNode.loc;
|
||||
throw createError(
|
||||
"Leading decorators must be attached to a class declaration",
|
||||
{
|
||||
start: { line: start.line, column: start.column + 1 },
|
||||
end: { line: end.line, column: end.column + 1 },
|
||||
}
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Keep Babel's non-standard ParenthesizedExpression nodes only if they have Closure-style type cast comments.
|
||||
if (
|
||||
options.parser !== "typescript" &&
|
||||
@@ -146,9 +191,9 @@ function postprocess(ast, options) {
|
||||
}
|
||||
}
|
||||
|
||||
// This is a workaround to transform `ChainExpression` from `espree` into
|
||||
// `babel` shape AST, we should do the opposite, since `ChainExpression` is the
|
||||
// standard `estree` AST for `optional chaining`
|
||||
// This is a workaround to transform `ChainExpression` from `espree`, `meriyah`,
|
||||
// and `typescript` into `babel` shape AST, we should do the opposite,
|
||||
// since `ChainExpression` is the standard `estree` AST for `optional chaining`
|
||||
// https://github.com/estree/estree/blob/master/es2020.md
|
||||
function transformChainExpression(node) {
|
||||
if (node.type === "CallExpression") {
|
||||
@@ -158,6 +203,10 @@ function transformChainExpression(node) {
|
||||
node.type = "OptionalMemberExpression";
|
||||
node.object = transformChainExpression(node.object);
|
||||
}
|
||||
// typescript
|
||||
else if (node.type === "TSNonNullExpression") {
|
||||
node.expression = transformChainExpression(node.expression);
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
@@ -180,6 +229,10 @@ function visitNode(node, fn) {
|
||||
node[key] = visitNode(child, fn);
|
||||
}
|
||||
|
||||
if (Array.isArray(node)) {
|
||||
return node;
|
||||
}
|
||||
|
||||
return fn(node) || node;
|
||||
}
|
||||
|
||||
|
||||
@@ -7,14 +7,14 @@ const postprocess = require("./parse-postprocess");
|
||||
|
||||
function parse(text, parsers, opts) {
|
||||
const jsx = isProbablyJsx(text);
|
||||
let ast;
|
||||
let result;
|
||||
try {
|
||||
// Try passing with our best guess first.
|
||||
ast = tryParseTypeScript(text, jsx);
|
||||
result = tryParseTypeScript(text, jsx);
|
||||
} catch (firstError) {
|
||||
try {
|
||||
// But if we get it wrong, try the opposite.
|
||||
ast = tryParseTypeScript(text, !jsx);
|
||||
result = tryParseTypeScript(text, !jsx);
|
||||
} catch (secondError) {
|
||||
// Suppose our guess is correct, throw the first error
|
||||
const { message, lineNumber, column } = firstError;
|
||||
@@ -30,12 +30,16 @@ function parse(text, parsers, opts) {
|
||||
}
|
||||
}
|
||||
|
||||
return postprocess(ast, { ...opts, originalText: text });
|
||||
return postprocess(result.ast, {
|
||||
...opts,
|
||||
originalText: text,
|
||||
tsParseResult: result,
|
||||
});
|
||||
}
|
||||
|
||||
function tryParseTypeScript(text, jsx) {
|
||||
const parser = require("@typescript-eslint/typescript-estree");
|
||||
return parser.parse(text, {
|
||||
const { parseWithNodeMaps } = require("@typescript-eslint/typescript-estree");
|
||||
return parseWithNodeMaps(text, {
|
||||
// `jest@<=26.4.2` rely on `loc`
|
||||
// https://github.com/facebook/jest/issues/10444
|
||||
loc: true,
|
||||
@@ -45,6 +49,7 @@ function tryParseTypeScript(text, jsx) {
|
||||
jsx,
|
||||
tokens: true,
|
||||
loggerFn: false,
|
||||
project: [],
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -24,17 +24,24 @@ const {
|
||||
|
||||
function printTemplateLiteral(path, print, options) {
|
||||
const node = path.getValue();
|
||||
const parentNode = path.getParentNode();
|
||||
const isTemplateLiteral = node.type === "TemplateLiteral";
|
||||
|
||||
if (isJestEachTemplateLiteral(node, parentNode)) {
|
||||
if (
|
||||
isTemplateLiteral &&
|
||||
isJestEachTemplateLiteral(node, path.getParentNode())
|
||||
) {
|
||||
const printed = printJestEachTemplateLiteral(path, options, print);
|
||||
if (printed) {
|
||||
return printed;
|
||||
}
|
||||
}
|
||||
let expressionsKey = "expressions";
|
||||
if (node.type === "TSTemplateLiteralType") {
|
||||
expressionsKey = "types";
|
||||
}
|
||||
const parts = [];
|
||||
|
||||
let expressions = path.map(print, "expressions");
|
||||
let expressions = path.map(print, expressionsKey);
|
||||
const isSimple = isSimpleTemplateLiteral(node);
|
||||
|
||||
if (isSimple) {
|
||||
@@ -70,7 +77,7 @@ function printTemplateLiteral(path, print, options) {
|
||||
let printed = expressions[i];
|
||||
|
||||
if (!isSimple) {
|
||||
const expression = node.expressions[i];
|
||||
const expression = node[expressionsKey][i];
|
||||
// Breaks at the template element boundaries (${ and }) are preferred to breaking
|
||||
// in the middle of a MemberExpression
|
||||
if (
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
"use strict";
|
||||
|
||||
const { concat, hardline, indent, join } = require("../document").builders;
|
||||
const {
|
||||
builders: { concat, hardline, indent, join },
|
||||
} = require("../document");
|
||||
const preprocess = require("./print-preprocess");
|
||||
|
||||
function genericPrint(path, options, print) {
|
||||
|
||||
@@ -2238,6 +2238,7 @@ function printPathNoParens(path, options, print, args) {
|
||||
return concat(parts);
|
||||
case "TemplateElement":
|
||||
return join(literalline, n.value.raw.split(/\r?\n/g));
|
||||
case "TSTemplateLiteralType":
|
||||
case "TemplateLiteral": {
|
||||
return printTemplateLiteral(path, print, options);
|
||||
}
|
||||
|
||||
@@ -464,6 +464,7 @@ const simpleTypeAnnotations = new Set([
|
||||
"BigIntLiteralTypeAnnotation",
|
||||
"NumberLiteralTypeAnnotation",
|
||||
"TSLiteralType",
|
||||
"TSTemplateLiteralType",
|
||||
// flow only, `empty`, `mixed`
|
||||
"EmptyTypeAnnotation",
|
||||
"MixedTypeAnnotation",
|
||||
@@ -647,11 +648,17 @@ function isNgForOf(node, index, parentNode) {
|
||||
* @returns {boolean}
|
||||
*/
|
||||
function isSimpleTemplateLiteral(node) {
|
||||
if (node.expressions.length === 0) {
|
||||
let expressionsKey = "expressions";
|
||||
if (node.type === "TSTemplateLiteralType") {
|
||||
expressionsKey = "types";
|
||||
}
|
||||
const expressions = node[expressionsKey];
|
||||
|
||||
if (expressions.length === 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return node.expressions.every((expr) => {
|
||||
return expressions.every((expr) => {
|
||||
// Disallow comments since printDocToString can't print them here
|
||||
if (expr.comments) {
|
||||
return false;
|
||||
|
||||
+11
-9
@@ -4,15 +4,17 @@
|
||||
const assert = require("assert");
|
||||
|
||||
const {
|
||||
concat,
|
||||
line,
|
||||
hardline,
|
||||
breakParent,
|
||||
indent,
|
||||
lineSuffix,
|
||||
join,
|
||||
cursor,
|
||||
} = require("../document").builders;
|
||||
builders: {
|
||||
concat,
|
||||
line,
|
||||
hardline,
|
||||
breakParent,
|
||||
indent,
|
||||
lineSuffix,
|
||||
join,
|
||||
cursor,
|
||||
},
|
||||
} = require("../document");
|
||||
|
||||
const {
|
||||
hasNewline,
|
||||
|
||||
@@ -0,0 +1,96 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`decorator.ts [babel-ts] format 1`] = `
|
||||
"Leading decorators must be attached to a class declaration (4:1)
|
||||
2 |
|
||||
3 | @dec
|
||||
> 4 | enum E {}
|
||||
| ^
|
||||
5 | "
|
||||
`;
|
||||
|
||||
exports[`decorator.ts [typescript] format 1`] = `
|
||||
"Leading decorators must be attached to a class declaration (3:1)
|
||||
1 | declare function dec<T>(target: T): T;
|
||||
2 |
|
||||
> 3 | @dec
|
||||
| ^^^^
|
||||
> 4 | enum E {}
|
||||
| ^^^^^^^^^^
|
||||
5 | "
|
||||
`;
|
||||
|
||||
exports[`enums.ts [babel-ts] format 1`] = `
|
||||
"Leading decorators must be attached to a class declaration (4:1)
|
||||
2 |
|
||||
3 | @decorator()
|
||||
> 4 | enum Direction {
|
||||
| ^
|
||||
5 | Up = 1,
|
||||
6 | Down,
|
||||
7 | Left,"
|
||||
`;
|
||||
|
||||
exports[`enums.ts [typescript] format 1`] = `
|
||||
"Leading decorators must be attached to a class declaration (3:1)
|
||||
1 | // https://github.com/typescript-eslint/typescript-eslint/pull/2375
|
||||
2 |
|
||||
> 3 | @decorator()
|
||||
| ^^^^^^^^^^^^
|
||||
> 4 | enum Direction {
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
> 5 | Up = 1,
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
> 6 | Down,
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
> 7 | Left,
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
> 8 | Right
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
> 9 | }
|
||||
| ^^
|
||||
10 | "
|
||||
`;
|
||||
|
||||
exports[`function.ts [babel-ts] format 1`] = `
|
||||
"Leading decorators must be attached to a class declaration (4:1)
|
||||
2 |
|
||||
3 | @decorator()
|
||||
> 4 | function foo( ){}
|
||||
| ^
|
||||
5 | "
|
||||
`;
|
||||
|
||||
exports[`function.ts [typescript] format 1`] = `
|
||||
"Leading decorators must be attached to a class declaration (3:1)
|
||||
1 | // https://github.com/typescript-eslint/typescript-eslint/pull/2375
|
||||
2 |
|
||||
> 3 | @decorator()
|
||||
| ^^^^^^^^^^^^
|
||||
> 4 | function foo( ){}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^
|
||||
5 | "
|
||||
`;
|
||||
|
||||
exports[`interface.ts [babel-ts] format 1`] = `
|
||||
"Leading decorators must be attached to a class declaration (5:1)
|
||||
3 |
|
||||
4 | @hello()
|
||||
> 5 | interface MyInterface {id: string;
|
||||
| ^
|
||||
6 | }
|
||||
7 | "
|
||||
`;
|
||||
|
||||
exports[`interface.ts [typescript] format 1`] = `
|
||||
"Leading decorators must be attached to a class declaration (4:1)
|
||||
2 | // #4632
|
||||
3 |
|
||||
> 4 | @hello()
|
||||
| ^^^^^^^^
|
||||
> 5 | interface MyInterface {id: string;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
> 6 | }
|
||||
| ^^
|
||||
7 | "
|
||||
`;
|
||||
File renamed without changes.
@@ -0,0 +1,9 @@
|
||||
// https://github.com/typescript-eslint/typescript-eslint/pull/2375
|
||||
|
||||
@decorator()
|
||||
enum Direction {
|
||||
Up = 1,
|
||||
Down,
|
||||
Left,
|
||||
Right
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
// https://github.com/typescript-eslint/typescript-eslint/pull/2375
|
||||
|
||||
@decorator()
|
||||
function foo( ){}
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
// invalid place but shouldn't be removed
|
||||
// #4632
|
||||
|
||||
@hello()
|
||||
interface MyInterface {
|
||||
id: string;
|
||||
interface MyInterface {id: string;
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
run_spec(__dirname, ["typescript", "babel-ts"]);
|
||||
@@ -1,30 +0,0 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`decorator.ts [babel-ts] format 1`] = `
|
||||
"Leading decorators must be attached to a class declaration (4:1)
|
||||
2 |
|
||||
3 | @dec
|
||||
> 4 | enum E {}
|
||||
| ^
|
||||
5 | "
|
||||
`;
|
||||
|
||||
exports[`decorator.ts format 1`] = `
|
||||
====================================options=====================================
|
||||
parsers: ["typescript"]
|
||||
printWidth: 80
|
||||
| printWidth
|
||||
=====================================input======================================
|
||||
declare function dec<T>(target: T): T;
|
||||
|
||||
@dec
|
||||
enum E {}
|
||||
|
||||
=====================================output=====================================
|
||||
declare function dec<T>(target: T): T;
|
||||
|
||||
@dec
|
||||
enum E {}
|
||||
|
||||
================================================================================
|
||||
`;
|
||||
@@ -1 +0,0 @@
|
||||
run_spec(__dirname, ["typescript"], { errors: { "babel-ts": true } });
|
||||
@@ -395,38 +395,3 @@ class MyContainerComponent {
|
||||
|
||||
================================================================================
|
||||
`;
|
||||
|
||||
exports[`interface.ts [babel-ts] format 1`] = `
|
||||
"Leading decorators must be attached to a class declaration (4:1)
|
||||
2 |
|
||||
3 | @hello()
|
||||
> 4 | interface MyInterface {
|
||||
| ^
|
||||
5 | id: string;
|
||||
6 | }
|
||||
7 | "
|
||||
`;
|
||||
|
||||
exports[`interface.ts format 1`] = `
|
||||
====================================options=====================================
|
||||
parsers: ["typescript"]
|
||||
printWidth: 80
|
||||
| printWidth
|
||||
=====================================input======================================
|
||||
// invalid place but shouldn't be removed
|
||||
|
||||
@hello()
|
||||
interface MyInterface {
|
||||
id: string;
|
||||
}
|
||||
|
||||
=====================================output=====================================
|
||||
// invalid place but shouldn't be removed
|
||||
|
||||
@hello()
|
||||
interface MyInterface {
|
||||
id: string;
|
||||
}
|
||||
|
||||
================================================================================
|
||||
`;
|
||||
@@ -1,3 +1 @@
|
||||
run_spec(__dirname, ["typescript"], {
|
||||
errors: { "babel-ts": ["interface.ts"] },
|
||||
});
|
||||
run_spec(__dirname, ["typescript"]);
|
||||
@@ -1,15 +1,5 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`key-remapping.ts [typescript] format 1`] = `
|
||||
"']' expected. (2:17)
|
||||
1 | type MappedTypeWithNewKeys<T> = {
|
||||
> 2 | [K in keyof T as NewKeyType]: T[K]
|
||||
| ^
|
||||
3 | };
|
||||
4 |
|
||||
5 | type RemoveKindField<T> = {"
|
||||
`;
|
||||
|
||||
exports[`key-remapping.ts format 1`] = `
|
||||
====================================options=====================================
|
||||
parsers: ["babel-ts", "typescript"]
|
||||
|
||||
@@ -1,3 +1 @@
|
||||
run_spec(__dirname, ["babel-ts", "typescript"], {
|
||||
errors: { typescript: true },
|
||||
});
|
||||
run_spec(__dirname, ["babel-ts", "typescript"]);
|
||||
@@ -1,14 +1,5 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`template-literal-types.ts [typescript] format 1`] = `
|
||||
"Type expected. (1:8)
|
||||
> 1 | let x: \`foo-\${infer bar}\`;
|
||||
| ^
|
||||
2 | type HelloWorld = \`\${Hello}, \${World}\`
|
||||
3 | type SeussFish = \`\${Quantity | Color} fish\`;
|
||||
4 | declare function setAlignment(value: \`\${VerticalAlignment}-\${HorizontalAlignment}\`): void;"
|
||||
`;
|
||||
|
||||
exports[`template-literal-types.ts format 1`] = `
|
||||
====================================options=====================================
|
||||
parsers: ["babel-ts", "typescript"]
|
||||
|
||||
@@ -1,3 +1 @@
|
||||
run_spec(__dirname, ["babel-ts", "typescript"], {
|
||||
errors: { typescript: true },
|
||||
});
|
||||
run_spec(__dirname, ["babel-ts", "typescript"]);
|
||||
@@ -71,6 +71,41 @@ const foo12: Foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
|
||||
================================================================================
|
||||
`;
|
||||
|
||||
exports[`template-literal-types.ts [babel] format 1`] = `
|
||||
"Unexpected token (1:84)
|
||||
> 1 | const foo1: Fooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo<\`Hello, \${keyof World}\`> = a;
|
||||
| ^
|
||||
2 | "
|
||||
`;
|
||||
|
||||
exports[`template-literal-types.ts [babel-flow] format 1`] = `
|
||||
"Unexpected token (1:84)
|
||||
> 1 | const foo1: Fooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo<\`Hello, \${keyof World}\`> = a;
|
||||
| ^
|
||||
2 | "
|
||||
`;
|
||||
|
||||
exports[`template-literal-types.ts [flow] format 1`] = `
|
||||
"Unexpected token \`\`\` (1:84)
|
||||
> 1 | const foo1: Fooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo<\`Hello, \${keyof World}\`> = a;
|
||||
| ^
|
||||
2 | "
|
||||
`;
|
||||
|
||||
exports[`template-literal-types.ts format 1`] = `
|
||||
====================================options=====================================
|
||||
parsers: ["typescript", "flow", "babel-flow", "babel"]
|
||||
printWidth: 80
|
||||
| printWidth
|
||||
=====================================input======================================
|
||||
const foo1: Fooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo<\`Hello, \${keyof World}\`> = a;
|
||||
|
||||
=====================================output=====================================
|
||||
const foo1: Fooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo<\`Hello, \${keyof World}\`> = a;
|
||||
|
||||
================================================================================
|
||||
`;
|
||||
|
||||
exports[`typescript-only.ts format 1`] = `
|
||||
====================================options=====================================
|
||||
parsers: ["typescript", "flow", "babel-flow", "babel"]
|
||||
@@ -81,6 +116,7 @@ const foo1: Fooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
|
||||
const foo2: Fooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo<object> = a;
|
||||
const foo3: Fooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo<undefined> = a;
|
||||
const foo4: Fooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo<unknown> = a;
|
||||
|
||||
=====================================output=====================================
|
||||
const foo1: Fooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo<never> = a;
|
||||
const foo2: Fooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo<object> = a;
|
||||
|
||||
@@ -1 +1,7 @@
|
||||
run_spec(__dirname, ["typescript", "flow", "babel-flow", "babel"]);
|
||||
run_spec(__dirname, ["typescript", "flow", "babel-flow", "babel"], {
|
||||
errors: {
|
||||
flow: ["template-literal-types.ts"],
|
||||
"babel-flow": ["template-literal-types.ts"],
|
||||
babel: ["template-literal-types.ts"],
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1 @@
|
||||
const foo1: Fooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo<`Hello, ${keyof World}`> = a;
|
||||
@@ -1,4 +1,4 @@
|
||||
const foo1: Fooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo<never> = a;
|
||||
const foo2: Fooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo<object> = a;
|
||||
const foo3: Fooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo<undefined> = a;
|
||||
const foo4: Fooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo<unknown> = a;
|
||||
const foo4: Fooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo<unknown> = a;
|
||||
@@ -1465,19 +1465,10 @@
|
||||
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-4.0.1.tgz#1cf72582f764931f085cb8230ff215980fe467b2"
|
||||
integrity sha512-S+gD3fgbkZYW2rnbjugNMqibm9HpEjqZBZkTiI3PwbbNGWmAcxolWIUwZ0SKeG4Dy2ktpKKaI/6+HGYVH8Qrlg==
|
||||
|
||||
"@typescript-eslint/typescript-estree@3.10.1":
|
||||
version "3.10.1"
|
||||
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-3.10.1.tgz#fd0061cc38add4fad45136d654408569f365b853"
|
||||
integrity sha512-QbcXOuq6WYvnB3XPsZpIwztBoquEYLXh2MtwVU+kO8jgYCiv4G5xrSP/1wg4tkvrEE+esZVquIPX/dxPlePk1w==
|
||||
dependencies:
|
||||
"@typescript-eslint/types" "3.10.1"
|
||||
"@typescript-eslint/visitor-keys" "3.10.1"
|
||||
debug "^4.1.1"
|
||||
glob "^7.1.6"
|
||||
is-glob "^4.0.1"
|
||||
lodash "^4.17.15"
|
||||
semver "^7.3.2"
|
||||
tsutils "^3.17.1"
|
||||
"@typescript-eslint/types@4.8.1":
|
||||
version "4.8.1"
|
||||
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-4.8.1.tgz#23829c73c5fc6f4fcd5346a7780b274f72fee222"
|
||||
integrity sha512-ave2a18x2Y25q5K05K/U3JQIe2Av4+TNi/2YuzyaXLAsDx6UZkz1boZ7nR/N6Wwae2PpudTZmHFXqu7faXfHmA==
|
||||
|
||||
"@typescript-eslint/typescript-estree@4.0.1":
|
||||
version "4.0.1"
|
||||
@@ -1493,12 +1484,19 @@
|
||||
semver "^7.3.2"
|
||||
tsutils "^3.17.1"
|
||||
|
||||
"@typescript-eslint/visitor-keys@3.10.1":
|
||||
version "3.10.1"
|
||||
resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-3.10.1.tgz#cd4274773e3eb63b2e870ac602274487ecd1e931"
|
||||
integrity sha512-9JgC82AaQeglebjZMgYR5wgmfUdUc+EitGUUMW8u2nDckaeimzW+VsoLV6FoimPv2id3VQzfjwBxEMVz08ameQ==
|
||||
"@typescript-eslint/typescript-estree@4.8.1":
|
||||
version "4.8.1"
|
||||
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-4.8.1.tgz#7307e3f2c9e95df7daa8dc0a34b8c43b7ec0dd32"
|
||||
integrity sha512-bJ6Fn/6tW2g7WIkCWh3QRlaSU7CdUUK52shx36/J7T5oTQzANvi6raoTsbwGM11+7eBbeem8hCCKbyvAc0X3sQ==
|
||||
dependencies:
|
||||
eslint-visitor-keys "^1.1.0"
|
||||
"@typescript-eslint/types" "4.8.1"
|
||||
"@typescript-eslint/visitor-keys" "4.8.1"
|
||||
debug "^4.1.1"
|
||||
globby "^11.0.1"
|
||||
is-glob "^4.0.1"
|
||||
lodash "^4.17.15"
|
||||
semver "^7.3.2"
|
||||
tsutils "^3.17.1"
|
||||
|
||||
"@typescript-eslint/visitor-keys@4.0.1":
|
||||
version "4.0.1"
|
||||
@@ -1508,6 +1506,14 @@
|
||||
"@typescript-eslint/types" "4.0.1"
|
||||
eslint-visitor-keys "^2.0.0"
|
||||
|
||||
"@typescript-eslint/visitor-keys@4.8.1":
|
||||
version "4.8.1"
|
||||
resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-4.8.1.tgz#794f68ee292d1b2e3aa9690ebedfcb3a8c90e3c3"
|
||||
integrity sha512-3nrwXFdEYALQh/zW8rFwP4QltqsanCDz4CwWMPiIZmwlk9GlvBeueEIbq05SEq4ganqM0g9nh02xXgv5XI3PeQ==
|
||||
dependencies:
|
||||
"@typescript-eslint/types" "4.8.1"
|
||||
eslint-visitor-keys "^2.0.0"
|
||||
|
||||
"@webassemblyjs/ast@1.9.0":
|
||||
version "1.9.0"
|
||||
resolved "https://registry.yarnpkg.com/@webassemblyjs/ast/-/ast-1.9.0.tgz#bd850604b4042459a5a41cd7d338cbed695ed964"
|
||||
@@ -7165,10 +7171,10 @@ typedarray-to-buffer@^3.1.5:
|
||||
dependencies:
|
||||
is-typedarray "^1.0.0"
|
||||
|
||||
typescript@4.0.5:
|
||||
version "4.0.5"
|
||||
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.0.5.tgz#ae9dddfd1069f1cb5beb3ef3b2170dd7c1332389"
|
||||
integrity sha512-ywmr/VrTVCmNTJ6iV2LwIrfG1P+lv6luD8sUJs+2eI9NLGigaN+nUQc13iHqisq7bra9lnmUSYqbJvegraBOPQ==
|
||||
typescript@4.1.1-rc:
|
||||
version "4.1.1-rc"
|
||||
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.1.1-rc.tgz#4a335244b9b2754995849ca4b607c74d6ee73719"
|
||||
integrity sha512-tgNcFrLIjlaMWEc7bKC0bxLNIt8BIAauY/HLUOQDyTP75HGskETtXOt46x4EKAHRKhWVLMc7yM02puTHa/yhCA==
|
||||
|
||||
unherit@^1.0.4:
|
||||
version "1.1.3"
|
||||
|
||||
Reference in new issue
Block a user