From ecc0ed4978b292c11fb81e3a2f9152016a56cb81 Mon Sep 17 00:00:00 2001 From: Brad Zacher Date: Sat, 22 May 2021 10:35:29 -0700 Subject: [PATCH 1/2] chore: update typescript to 4.3-rc Ref #3272 --- README.md | 2 +- package.json | 4 ++-- .../eslint-plugin/src/rules/dot-notation.ts | 1 + packages/typescript-estree/package.json | 4 ++-- packages/typescript-estree/src/convert.ts | 2 +- packages/typescript-estree/src/parser.ts | 4 ++-- .../tests/ast-alignment/utils.ts | 4 ++++ .../lib/__snapshots__/convert.test.ts.snap | 7 ------- .../typescript-estree/tests/lib/convert.test.ts | 3 +-- .../jsx/namespace-this-name.src.js.shot | 2 +- .../enum-with-keywords.src.ts.shot | 6 ------ yarn.lock | 17 +++++++++++------ 12 files changed, 26 insertions(+), 30 deletions(-) diff --git a/README.md b/README.md index d8abbe324a9..25a1a58f3ed 100644 --- a/README.md +++ b/README.md @@ -233,7 +233,7 @@ The latest version under the `canary` tag **(latest commit to master)** is: ## Supported TypeScript Version -**The version range of TypeScript currently supported by this parser is `>=3.3.1 <4.3.0`.** +**The version range of TypeScript currently supported by this parser is `>=3.3.1 <4.4.0`.** These versions are what we test against. diff --git a/package.json b/package.json index 61fff853321..ea5995ab64d 100644 --- a/package.json +++ b/package.json @@ -113,9 +113,9 @@ "ts-jest": "^26.5.1", "ts-node": "^9.0.0", "tslint": "^6.1.3", - "typescript": ">=3.3.1 <4.3.0" + "typescript": ">=3.3.1 <4.4.0 || 4.3.1-rc" }, "resolutions": { - "typescript": "4.2.2" + "typescript": "4.3.1-rc" } } diff --git a/packages/eslint-plugin/src/rules/dot-notation.ts b/packages/eslint-plugin/src/rules/dot-notation.ts index 055b97ecab2..b93dc8d035a 100644 --- a/packages/eslint-plugin/src/rules/dot-notation.ts +++ b/packages/eslint-plugin/src/rules/dot-notation.ts @@ -77,6 +77,7 @@ export default createRule({ (options.allowIndexSignaturePropertyAccess ?? false) || tsutils.isCompilerOptionEnabled( program.getCompilerOptions(), + // @ts-expect-error - TS is refining the type to never for some reason 'noPropertyAccessFromIndexSignature', ); diff --git a/packages/typescript-estree/package.json b/packages/typescript-estree/package.json index a350c25ef9d..15e1ec911bc 100644 --- a/packages/typescript-estree/package.json +++ b/packages/typescript-estree/package.json @@ -51,8 +51,8 @@ }, "devDependencies": { "@babel/code-frame": "^7.12.13", - "@babel/parser": "^7.13.11", - "@babel/types": "^7.13.0", + "@babel/parser": "^7.14.3", + "@babel/types": "^7.14.2", "@types/babel__code-frame": "*", "@types/debug": "*", "@types/glob": "*", diff --git a/packages/typescript-estree/src/convert.ts b/packages/typescript-estree/src/convert.ts index aad29f9b146..3f14454384d 100644 --- a/packages/typescript-estree/src/convert.ts +++ b/packages/typescript-estree/src/convert.ts @@ -500,7 +500,7 @@ export class Converter { Object.entries(node) .filter( ([key]) => - !/^(?:_children|kind|parent|pos|end|flags|modifierFlagsCache|jsDoc|type|typeArguments|typeParameters|decorators)$/.test( + !/^(?:_children|kind|parent|pos|end|flags|modifierFlagsCache|jsDoc|type|typeArguments|typeParameters|decorators|transformFlags)$/.test( key, ), ) diff --git a/packages/typescript-estree/src/parser.ts b/packages/typescript-estree/src/parser.ts index 300a73c6f1d..fdbeaa6fa06 100644 --- a/packages/typescript-estree/src/parser.ts +++ b/packages/typescript-estree/src/parser.ts @@ -25,12 +25,12 @@ const log = debug('typescript-eslint:typescript-estree:parser'); * This needs to be kept in sync with the top-level README.md in the * typescript-eslint monorepo */ -const SUPPORTED_TYPESCRIPT_VERSIONS = '>=3.3.1 <4.3.0'; +const SUPPORTED_TYPESCRIPT_VERSIONS = '>=3.3.1 <4.4.0'; /* * The semver package will ignore prerelease ranges, and we don't want to explicitly document every one * List them all separately here, so we can automatically create the full string */ -const SUPPORTED_PRERELEASE_RANGES: string[] = ['4.1.1-rc', '4.1.0-beta']; +const SUPPORTED_PRERELEASE_RANGES: string[] = ['4.3.0-beta', '4.3.1-rc']; const ACTIVE_TYPESCRIPT_VERSION = ts.version; const isRunningSupportedTypeScriptVersion = semver.satisfies( ACTIVE_TYPESCRIPT_VERSION, diff --git a/packages/typescript-estree/tests/ast-alignment/utils.ts b/packages/typescript-estree/tests/ast-alignment/utils.ts index 99956cb694f..b0c7c990553 100644 --- a/packages/typescript-estree/tests/ast-alignment/utils.ts +++ b/packages/typescript-estree/tests/ast-alignment/utils.ts @@ -126,6 +126,10 @@ export function preprocessBabylonAST(ast: BabelTypes.File): any { node.params = node.parameters; delete node.parameters; } + if (node.kind) { + // TODO - remove this once we support accessor signatures + delete node.kind; + } }, /** * We want this node to be different diff --git a/packages/typescript-estree/tests/lib/__snapshots__/convert.test.ts.snap b/packages/typescript-estree/tests/lib/__snapshots__/convert.test.ts.snap index 7da28080eb3..ef7abcee4f4 100644 --- a/packages/typescript-estree/tests/lib/__snapshots__/convert.test.ts.snap +++ b/packages/typescript-estree/tests/lib/__snapshots__/convert.test.ts.snap @@ -22,7 +22,6 @@ Object { 12, 12, ], - "transformFlags": 0, "type": "TSEndOfFileToken", }, "externalModuleIndicator": undefined, @@ -170,7 +169,6 @@ Object { }, ], "text": "new foo()", - "transformFlags": 9, "type": "TSSourceFile", "typeReferenceDirectives": Array [], } @@ -210,7 +208,6 @@ Object { 5, 8, ], - "transformFlags": 0, "type": "TSUnparsedPrologue", }, "nextContainer": undefined, @@ -219,7 +216,6 @@ Object { 35, ], "symbol": undefined, - "transformFlags": 1, "type": "TSUnparsedPrologue", "typeAnnotation": null, "typeParameters": null, @@ -322,7 +318,6 @@ Object { 18, ], "symbol": undefined, - "transformFlags": 2305, "type": "TSClassDeclaration", "typeParameters": null, } @@ -363,7 +358,6 @@ Object { 0, 12, ], - "transformFlags": 9, "type": "TSNewExpression", "typeParameters": Object { "loc": Object { @@ -464,7 +458,6 @@ Object { 15, ], "symbol": undefined, - "transformFlags": 257, "type": "TSClassDeclaration", "typeParameters": Object { "loc": Object { diff --git a/packages/typescript-estree/tests/lib/convert.test.ts b/packages/typescript-estree/tests/lib/convert.test.ts index a95916138d7..b26390b7f75 100644 --- a/packages/typescript-estree/tests/lib/convert.test.ts +++ b/packages/typescript-estree/tests/lib/convert.test.ts @@ -19,8 +19,7 @@ describe('convert', () => { function fakeUnknownKind(node: ts.Node): void { ts.forEachChild(node, fakeUnknownKind); - // eslint-disable-next-line @typescript-eslint/ban-ts-comment -- intentionally writing to a readonly field - // @ts-expect-error + // @ts-expect-error -- intentionally writing to a readonly field node.kind = ts.SyntaxKind.UnparsedPrologue; } diff --git a/packages/typescript-estree/tests/snapshots/jsx/namespace-this-name.src.js.shot b/packages/typescript-estree/tests/snapshots/jsx/namespace-this-name.src.js.shot index 58e66b804b7..46d67089584 100644 --- a/packages/typescript-estree/tests/snapshots/jsx/namespace-this-name.src.js.shot +++ b/packages/typescript-estree/tests/snapshots/jsx/namespace-this-name.src.js.shot @@ -163,7 +163,7 @@ Object { 1, 9, ], - "type": "Keyword", + "type": "JSXIdentifier", "value": "this:bar", }, Object { diff --git a/packages/typescript-estree/tests/snapshots/typescript/errorRecovery/enum-with-keywords.src.ts.shot b/packages/typescript-estree/tests/snapshots/typescript/errorRecovery/enum-with-keywords.src.ts.shot index 2a93eb27f3d..8eb4625590f 100644 --- a/packages/typescript-estree/tests/snapshots/typescript/errorRecovery/enum-with-keywords.src.ts.shot +++ b/packages/typescript-estree/tests/snapshots/typescript/errorRecovery/enum-with-keywords.src.ts.shot @@ -50,7 +50,6 @@ Object { 7, 14, ], - "transformFlags": 1, "type": "TSPrivateKeyword", }, Object { @@ -68,7 +67,6 @@ Object { 15, 21, ], - "transformFlags": 1, "type": "TSPublicKeyword", }, Object { @@ -86,7 +84,6 @@ Object { 22, 31, ], - "transformFlags": 1, "type": "TSProtectedKeyword", }, Object { @@ -104,7 +101,6 @@ Object { 32, 38, ], - "transformFlags": 256, "type": "TSStaticKeyword", }, Object { @@ -122,7 +118,6 @@ Object { 39, 47, ], - "transformFlags": 1, "type": "TSReadonlyKeyword", }, Object { @@ -157,7 +152,6 @@ Object { 57, 62, ], - "transformFlags": 96, "type": "TSAsyncKeyword", }, ], diff --git a/yarn.lock b/yarn.lock index 2d44f73beda..281160f5ca1 100644 --- a/yarn.lock +++ b/yarn.lock @@ -171,11 +171,16 @@ chalk "^2.0.0" js-tokens "^4.0.0" -"@babel/parser@^7.1.0", "@babel/parser@^7.12.13", "@babel/parser@^7.13.0", "@babel/parser@^7.13.10", "@babel/parser@^7.13.11": +"@babel/parser@^7.1.0", "@babel/parser@^7.12.13", "@babel/parser@^7.13.0", "@babel/parser@^7.13.10": version "7.13.15" resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.13.15.tgz#8e66775fb523599acb6a289e12929fa5ab0954d8" integrity sha512-b9COtcAlVEQljy/9fbcMHpG+UIW9ReF+gpaxDHTlZd0c6/UU9ng8zdySAW9sRTzpvcdCHn6bUcbuYUgGzLAWVQ== +"@babel/parser@^7.14.3": + version "7.14.3" + resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.14.3.tgz#9b530eecb071fd0c93519df25c5ff9f14759f298" + integrity sha512-7MpZDIfI7sUC5zWo2+foJ50CSI5lcqDehZ0lVgIhSi4bFEk94fLAKlF3Q0nzSQQ+ca0lm+O6G9ztKVBeu8PMRQ== + "@babel/plugin-syntax-async-generators@^7.8.4": version "7.8.4" resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-async-generators/-/plugin-syntax-async-generators-7.8.4.tgz#a983fb1aeb2ec3f6ed042a210f640e90e786fe0d" @@ -291,7 +296,7 @@ globals "^11.1.0" lodash "^4.17.19" -"@babel/types@^7.0.0", "@babel/types@^7.12.13", "@babel/types@^7.13.0", "@babel/types@^7.3.0", "@babel/types@^7.3.3": +"@babel/types@^7.0.0", "@babel/types@^7.12.13", "@babel/types@^7.13.0", "@babel/types@^7.14.2", "@babel/types@^7.3.0", "@babel/types@^7.3.3": version "7.14.2" resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.14.2.tgz#4208ae003107ef8a057ea8333e56eb64d2f6a2c3" integrity sha512-SdjAG/3DikRHpUOjxZgnkbR11xUlyDMUFJdvnIgZEE16mqmY0BINMmc4//JMJglEmn6i7sq6p+mGrFWyZ98EEw== @@ -8858,10 +8863,10 @@ typedarray@^0.0.6: resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777" integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c= -typescript@*, typescript@4.2.2, "typescript@>=3.3.1 <4.3.0", typescript@^4.1.0-dev.20201026, typescript@~4.2.4: - version "4.2.2" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.2.2.tgz#1450f020618f872db0ea17317d16d8da8ddb8c4c" - integrity sha512-tbb+NVrLfnsJy3M59lsDgrzWIflR4d4TIUjz+heUnHZwdF7YsrMTKoRERiIvI2lvBG95dfpLxB21WZhys1bgaQ== +typescript@*, typescript@4.3.1-rc, "typescript@>=3.3.1 <4.4.0 || 4.3.1-rc", typescript@^4.1.0-dev.20201026, typescript@~4.2.4: + version "4.3.1-rc" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.3.1-rc.tgz#925149c8d8514e20a6bd8d4bd7f42adac67ab59c" + integrity sha512-L3uJ0gcntaRaKni9aV2amYB+pCDVodKe/B5+IREyvtKGsDOF7cYjchHb/B894skqkgD52ykRuWatIZMqEsHIqA== uc.micro@^1.0.1, uc.micro@^1.0.5: version "1.0.6" From 2687d433cb68c1b0fd0e4c47fbc220659149e6d8 Mon Sep 17 00:00:00 2001 From: Brad Zacher Date: Sat, 22 May 2021 11:15:22 -0700 Subject: [PATCH 2/2] feat(typescript-estree): add support for getter/setter signatures on types Ref #3272 --- .eslintrc.js | 4 + .../src/element/TSMethodSignature/spec.ts | 1 + .../types/interface-with-accessors.src.ts | 4 + .../object-literal-type-with-accessors.src.ts | 4 + packages/typescript-estree/src/convert.ts | 108 ++- .../src/ts-estree/estree-to-ts-node-types.ts | 5 +- .../tests/ast-alignment/utils.ts | 4 - .../semantic-diagnostics-enabled.test.ts.snap | 4 + .../export-default-interface.src.ts.shot | 1 + ...erface-with-all-property-types.src.ts.shot | 4 + .../basics/interface-with-jsdoc.src.ts.shot | 1 + .../basics/interface-with-method.src.ts.shot | 2 + ...rface-with-optional-properties.src.ts.shot | 1 + .../type-assertion-in-interface.src.ts.shot | 1 + ...ertion-with-guard-in-interface.src.ts.shot | 1 + .../type-guard-in-interface.src.ts.shot | 1 + .../basics/typed-method-signature.src.ts.shot | 2 + .../typescript/basics/typed-this.src.ts.shot | 1 + ...parameters-in-method-signature.src.ts.shot | 1 + .../interface-method-export.src.ts.shot | 1 + .../interface-method-private.src.ts.shot | 1 + .../interface-method-protected.src.ts.shot | 1 + .../interface-method-public.src.ts.shot | 1 + .../interface-method-readonly.src.ts.shot | 1 + .../interface-method-static.src.ts.shot | 1 + .../interface-with-accessors.src.ts.shot | 711 +++++++++++++++++ ...ct-literal-type-with-accessors.src.ts.shot | 747 ++++++++++++++++++ 27 files changed, 1570 insertions(+), 44 deletions(-) create mode 100644 packages/shared-fixtures/fixtures/typescript/types/interface-with-accessors.src.ts create mode 100644 packages/shared-fixtures/fixtures/typescript/types/object-literal-type-with-accessors.src.ts create mode 100644 packages/typescript-estree/tests/snapshots/typescript/types/interface-with-accessors.src.ts.shot create mode 100644 packages/typescript-estree/tests/snapshots/typescript/types/object-literal-type-with-accessors.src.ts.shot diff --git a/.eslintrc.js b/.eslintrc.js index c02abfbd7a8..1deda3b592c 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -87,6 +87,10 @@ module.exports = { 'no-mixed-operators': 'error', 'no-console': 'error', 'no-process-exit': 'error', + 'no-fallthrough': [ + 'warn', + { commentPattern: '.*intentional fallthrough.*' }, + ], // // eslint-plugin-eslint-comment diff --git a/packages/ast-spec/src/element/TSMethodSignature/spec.ts b/packages/ast-spec/src/element/TSMethodSignature/spec.ts index 76b2e71ab3a..5ca7cbead3e 100644 --- a/packages/ast-spec/src/element/TSMethodSignature/spec.ts +++ b/packages/ast-spec/src/element/TSMethodSignature/spec.ts @@ -22,6 +22,7 @@ interface TSMethodSignatureBase extends BaseNode { accessibility?: Accessibility; export?: boolean; static?: boolean; + kind: 'get' | 'method' | 'set'; } export interface TSMethodSignatureComputedName extends TSMethodSignatureBase { diff --git a/packages/shared-fixtures/fixtures/typescript/types/interface-with-accessors.src.ts b/packages/shared-fixtures/fixtures/typescript/types/interface-with-accessors.src.ts new file mode 100644 index 00000000000..d4eda64b218 --- /dev/null +++ b/packages/shared-fixtures/fixtures/typescript/types/interface-with-accessors.src.ts @@ -0,0 +1,4 @@ +interface Thing { + get size(): number; + set size(value: number | string | boolean); +} diff --git a/packages/shared-fixtures/fixtures/typescript/types/object-literal-type-with-accessors.src.ts b/packages/shared-fixtures/fixtures/typescript/types/object-literal-type-with-accessors.src.ts new file mode 100644 index 00000000000..61666608a10 --- /dev/null +++ b/packages/shared-fixtures/fixtures/typescript/types/object-literal-type-with-accessors.src.ts @@ -0,0 +1,4 @@ +type Thing = { + get size(): number; + set size(value: number | string | boolean); +}; diff --git a/packages/typescript-estree/src/convert.ts b/packages/typescript-estree/src/convert.ts index 3f14454384d..595d284237c 100644 --- a/packages/typescript-estree/src/convert.ts +++ b/packages/typescript-estree/src/convert.ts @@ -593,6 +593,65 @@ export class Converter { return result; } + private convertMethodSignature( + node: + | ts.MethodSignature + | ts.GetAccessorDeclaration + | ts.SetAccessorDeclaration, + ): TSESTree.TSMethodSignature { + const result = this.createNode(node, { + type: AST_NODE_TYPES.TSMethodSignature, + computed: isComputedProperty(node.name), + key: this.convertChild(node.name), + params: this.convertParameters(node.parameters), + kind: ((): 'get' | 'set' | 'method' => { + switch (node.kind) { + case SyntaxKind.GetAccessor: + return 'get'; + + case SyntaxKind.SetAccessor: + return 'set'; + + case SyntaxKind.MethodSignature: + return 'method'; + } + })(), + }); + + if (isOptional(node)) { + result.optional = true; + } + + if (node.type) { + result.returnType = this.convertTypeAnnotation(node.type, node); + } + + if (hasModifier(SyntaxKind.ReadonlyKeyword, node)) { + result.readonly = true; + } + + if (node.typeParameters) { + result.typeParameters = this.convertTSTypeParametersToTypeParametersDeclaration( + node.typeParameters, + ); + } + + const accessibility = getTSNodeAccessibility(node); + if (accessibility) { + result.accessibility = accessibility; + } + + if (hasModifier(SyntaxKind.ExportKeyword, node)) { + result.export = true; + } + + if (hasModifier(SyntaxKind.StaticKeyword, node)) { + result.static = true; + } + + return result; + } + /** * Applies the given TS modifiers to the given result object. * @param result @@ -1069,7 +1128,15 @@ export class Converter { } case SyntaxKind.GetAccessor: - case SyntaxKind.SetAccessor: + case SyntaxKind.SetAccessor: { + if ( + node.parent.kind === SyntaxKind.InterfaceDeclaration || + node.parent.kind === SyntaxKind.TypeLiteral + ) { + return this.convertMethodSignature(node); + } + } + // otherwise, it is a non-type accessor - intentional fallthrough case SyntaxKind.MethodDeclaration: { const method = this.createNode< TSESTree.TSEmptyBodyFunctionExpression | TSESTree.FunctionExpression @@ -2340,44 +2407,7 @@ export class Converter { } case SyntaxKind.MethodSignature: { - const result = this.createNode(node, { - type: AST_NODE_TYPES.TSMethodSignature, - computed: isComputedProperty(node.name), - key: this.convertChild(node.name), - params: this.convertParameters(node.parameters), - }); - - if (isOptional(node)) { - result.optional = true; - } - - if (node.type) { - result.returnType = this.convertTypeAnnotation(node.type, node); - } - - if (hasModifier(SyntaxKind.ReadonlyKeyword, node)) { - result.readonly = true; - } - - if (node.typeParameters) { - result.typeParameters = this.convertTSTypeParametersToTypeParametersDeclaration( - node.typeParameters, - ); - } - - const accessibility = getTSNodeAccessibility(node); - if (accessibility) { - result.accessibility = accessibility; - } - - if (hasModifier(SyntaxKind.ExportKeyword, node)) { - result.export = true; - } - - if (hasModifier(SyntaxKind.StaticKeyword, node)) { - result.static = true; - } - return result; + return this.convertMethodSignature(node); } case SyntaxKind.PropertySignature: { diff --git a/packages/typescript-estree/src/ts-estree/estree-to-ts-node-types.ts b/packages/typescript-estree/src/ts-estree/estree-to-ts-node-types.ts index 92ef8c42e60..0f74c42ac64 100644 --- a/packages/typescript-estree/src/ts-estree/estree-to-ts-node-types.ts +++ b/packages/typescript-estree/src/ts-estree/estree-to-ts-node-types.ts @@ -180,7 +180,10 @@ export interface EstreeToTsNodeTypes { [AST_NODE_TYPES.TSIntersectionType]: ts.IntersectionTypeNode; [AST_NODE_TYPES.TSLiteralType]: ts.LiteralTypeNode; [AST_NODE_TYPES.TSMappedType]: ts.MappedTypeNode; - [AST_NODE_TYPES.TSMethodSignature]: ts.MethodSignature; + [AST_NODE_TYPES.TSMethodSignature]: + | ts.MethodSignature + | ts.GetAccessorDeclaration + | ts.SetAccessorDeclaration; [AST_NODE_TYPES.TSModuleBlock]: ts.ModuleBlock; [AST_NODE_TYPES.TSModuleDeclaration]: ts.ModuleDeclaration; [AST_NODE_TYPES.TSNamedTupleMember]: ts.NamedTupleMember; diff --git a/packages/typescript-estree/tests/ast-alignment/utils.ts b/packages/typescript-estree/tests/ast-alignment/utils.ts index b0c7c990553..99956cb694f 100644 --- a/packages/typescript-estree/tests/ast-alignment/utils.ts +++ b/packages/typescript-estree/tests/ast-alignment/utils.ts @@ -126,10 +126,6 @@ export function preprocessBabylonAST(ast: BabelTypes.File): any { node.params = node.parameters; delete node.parameters; } - if (node.kind) { - // TODO - remove this once we support accessor signatures - delete node.kind; - } }, /** * We want this node to be different diff --git a/packages/typescript-estree/tests/lib/__snapshots__/semantic-diagnostics-enabled.test.ts.snap b/packages/typescript-estree/tests/lib/__snapshots__/semantic-diagnostics-enabled.test.ts.snap index 7094769a4ad..641c388c3ef 100644 --- a/packages/typescript-estree/tests/lib/__snapshots__/semantic-diagnostics-enabled.test.ts.snap +++ b/packages/typescript-estree/tests/lib/__snapshots__/semantic-diagnostics-enabled.test.ts.snap @@ -2639,6 +2639,8 @@ exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" e exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/types/indexed.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; +exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/types/interface-with-accessors.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; + exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/types/intersection-type.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/types/literal-number.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; @@ -2661,6 +2663,8 @@ exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" e exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/types/nested-types.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; +exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/types/object-literal-type-with-accessors.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; + exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/types/parenthesized-type.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/types/reference.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; diff --git a/packages/typescript-estree/tests/snapshots/typescript/basics/export-default-interface.src.ts.shot b/packages/typescript-estree/tests/snapshots/typescript/basics/export-default-interface.src.ts.shot index cfcdd7ad177..d7778592270 100644 --- a/packages/typescript-estree/tests/snapshots/typescript/basics/export-default-interface.src.ts.shot +++ b/packages/typescript-estree/tests/snapshots/typescript/basics/export-default-interface.src.ts.shot @@ -27,6 +27,7 @@ Object { ], "type": "Identifier", }, + "kind": "method", "loc": Object { "end": Object { "column": 18, diff --git a/packages/typescript-estree/tests/snapshots/typescript/basics/interface-with-all-property-types.src.ts.shot b/packages/typescript-estree/tests/snapshots/typescript/basics/interface-with-all-property-types.src.ts.shot index af58d87e382..dece748c4b2 100644 --- a/packages/typescript-estree/tests/snapshots/typescript/basics/interface-with-all-property-types.src.ts.shot +++ b/packages/typescript-estree/tests/snapshots/typescript/basics/interface-with-all-property-types.src.ts.shot @@ -431,6 +431,7 @@ Object { ], "type": "Identifier", }, + "kind": "method", "loc": Object { "end": Object { "column": 16, @@ -502,6 +503,7 @@ Object { ], "type": "Identifier", }, + "kind": "method", "loc": Object { "end": Object { "column": 24, @@ -629,6 +631,7 @@ Object { ], "type": "Identifier", }, + "kind": "method", "loc": Object { "end": Object { "column": 26, @@ -756,6 +759,7 @@ Object { ], "type": "Identifier", }, + "kind": "method", "loc": Object { "end": Object { "column": 26, diff --git a/packages/typescript-estree/tests/snapshots/typescript/basics/interface-with-jsdoc.src.ts.shot b/packages/typescript-estree/tests/snapshots/typescript/basics/interface-with-jsdoc.src.ts.shot index c20b0a2d981..c4299c7644c 100644 --- a/packages/typescript-estree/tests/snapshots/typescript/basics/interface-with-jsdoc.src.ts.shot +++ b/packages/typescript-estree/tests/snapshots/typescript/basics/interface-with-jsdoc.src.ts.shot @@ -26,6 +26,7 @@ Object { ], "type": "Identifier", }, + "kind": "method", "loc": Object { "end": Object { "column": 13, diff --git a/packages/typescript-estree/tests/snapshots/typescript/basics/interface-with-method.src.ts.shot b/packages/typescript-estree/tests/snapshots/typescript/basics/interface-with-method.src.ts.shot index 537cc8b236f..f94e3498298 100644 --- a/packages/typescript-estree/tests/snapshots/typescript/basics/interface-with-method.src.ts.shot +++ b/packages/typescript-estree/tests/snapshots/typescript/basics/interface-with-method.src.ts.shot @@ -26,6 +26,7 @@ Object { ], "type": "Identifier", }, + "kind": "method", "loc": Object { "end": Object { "column": 23, @@ -150,6 +151,7 @@ Object { ], "type": "Identifier", }, + "kind": "method", "loc": Object { "end": Object { "column": 18, diff --git a/packages/typescript-estree/tests/snapshots/typescript/basics/interface-with-optional-properties.src.ts.shot b/packages/typescript-estree/tests/snapshots/typescript/basics/interface-with-optional-properties.src.ts.shot index df83385dd28..f0d57792836 100644 --- a/packages/typescript-estree/tests/snapshots/typescript/basics/interface-with-optional-properties.src.ts.shot +++ b/packages/typescript-estree/tests/snapshots/typescript/basics/interface-with-optional-properties.src.ts.shot @@ -143,6 +143,7 @@ Object { ], "type": "Identifier", }, + "kind": "method", "loc": Object { "end": Object { "column": 34, diff --git a/packages/typescript-estree/tests/snapshots/typescript/basics/type-assertion-in-interface.src.ts.shot b/packages/typescript-estree/tests/snapshots/typescript/basics/type-assertion-in-interface.src.ts.shot index 06266e5337e..8cbbcfed1d5 100644 --- a/packages/typescript-estree/tests/snapshots/typescript/basics/type-assertion-in-interface.src.ts.shot +++ b/packages/typescript-estree/tests/snapshots/typescript/basics/type-assertion-in-interface.src.ts.shot @@ -26,6 +26,7 @@ Object { ], "type": "Identifier", }, + "kind": "method", "loc": Object { "end": Object { "column": 36, diff --git a/packages/typescript-estree/tests/snapshots/typescript/basics/type-assertion-with-guard-in-interface.src.ts.shot b/packages/typescript-estree/tests/snapshots/typescript/basics/type-assertion-with-guard-in-interface.src.ts.shot index eae14240799..a26782c1073 100644 --- a/packages/typescript-estree/tests/snapshots/typescript/basics/type-assertion-with-guard-in-interface.src.ts.shot +++ b/packages/typescript-estree/tests/snapshots/typescript/basics/type-assertion-with-guard-in-interface.src.ts.shot @@ -26,6 +26,7 @@ Object { ], "type": "Identifier", }, + "kind": "method", "loc": Object { "end": Object { "column": 46, diff --git a/packages/typescript-estree/tests/snapshots/typescript/basics/type-guard-in-interface.src.ts.shot b/packages/typescript-estree/tests/snapshots/typescript/basics/type-guard-in-interface.src.ts.shot index ff60f3be6e9..a7723369960 100644 --- a/packages/typescript-estree/tests/snapshots/typescript/basics/type-guard-in-interface.src.ts.shot +++ b/packages/typescript-estree/tests/snapshots/typescript/basics/type-guard-in-interface.src.ts.shot @@ -26,6 +26,7 @@ Object { ], "type": "Identifier", }, + "kind": "method", "loc": Object { "end": Object { "column": 38, diff --git a/packages/typescript-estree/tests/snapshots/typescript/basics/typed-method-signature.src.ts.shot b/packages/typescript-estree/tests/snapshots/typescript/basics/typed-method-signature.src.ts.shot index eefbf73554f..a175d632669 100644 --- a/packages/typescript-estree/tests/snapshots/typescript/basics/typed-method-signature.src.ts.shot +++ b/packages/typescript-estree/tests/snapshots/typescript/basics/typed-method-signature.src.ts.shot @@ -69,6 +69,7 @@ Object { ], "type": "Identifier", }, + "kind": "method", "loc": Object { "end": Object { "column": 23, @@ -193,6 +194,7 @@ Object { ], "type": "Identifier", }, + "kind": "method", "loc": Object { "end": Object { "column": 18, diff --git a/packages/typescript-estree/tests/snapshots/typescript/basics/typed-this.src.ts.shot b/packages/typescript-estree/tests/snapshots/typescript/basics/typed-this.src.ts.shot index 10ab794d02d..bfd4fd36e9e 100644 --- a/packages/typescript-estree/tests/snapshots/typescript/basics/typed-this.src.ts.shot +++ b/packages/typescript-estree/tests/snapshots/typescript/basics/typed-this.src.ts.shot @@ -26,6 +26,7 @@ Object { ], "type": "Identifier", }, + "kind": "method", "loc": Object { "end": Object { "column": 65, diff --git a/packages/typescript-estree/tests/snapshots/typescript/errorRecovery/empty-type-parameters-in-method-signature.src.ts.shot b/packages/typescript-estree/tests/snapshots/typescript/errorRecovery/empty-type-parameters-in-method-signature.src.ts.shot index 471b29c33cd..bb110cf0575 100644 --- a/packages/typescript-estree/tests/snapshots/typescript/errorRecovery/empty-type-parameters-in-method-signature.src.ts.shot +++ b/packages/typescript-estree/tests/snapshots/typescript/errorRecovery/empty-type-parameters-in-method-signature.src.ts.shot @@ -26,6 +26,7 @@ Object { ], "type": "Identifier", }, + "kind": "method", "loc": Object { "end": Object { "column": 11, diff --git a/packages/typescript-estree/tests/snapshots/typescript/errorRecovery/interface-method-export.src.ts.shot b/packages/typescript-estree/tests/snapshots/typescript/errorRecovery/interface-method-export.src.ts.shot index 2827b9747e8..49552e632b9 100644 --- a/packages/typescript-estree/tests/snapshots/typescript/errorRecovery/interface-method-export.src.ts.shot +++ b/packages/typescript-estree/tests/snapshots/typescript/errorRecovery/interface-method-export.src.ts.shot @@ -27,6 +27,7 @@ Object { ], "type": "Identifier", }, + "kind": "method", "loc": Object { "end": Object { "column": 32, diff --git a/packages/typescript-estree/tests/snapshots/typescript/errorRecovery/interface-method-private.src.ts.shot b/packages/typescript-estree/tests/snapshots/typescript/errorRecovery/interface-method-private.src.ts.shot index 6c4af209900..0b2fc02bfd5 100644 --- a/packages/typescript-estree/tests/snapshots/typescript/errorRecovery/interface-method-private.src.ts.shot +++ b/packages/typescript-estree/tests/snapshots/typescript/errorRecovery/interface-method-private.src.ts.shot @@ -27,6 +27,7 @@ Object { ], "type": "Identifier", }, + "kind": "method", "loc": Object { "end": Object { "column": 33, diff --git a/packages/typescript-estree/tests/snapshots/typescript/errorRecovery/interface-method-protected.src.ts.shot b/packages/typescript-estree/tests/snapshots/typescript/errorRecovery/interface-method-protected.src.ts.shot index e5159f9940b..1826aeadf4e 100644 --- a/packages/typescript-estree/tests/snapshots/typescript/errorRecovery/interface-method-protected.src.ts.shot +++ b/packages/typescript-estree/tests/snapshots/typescript/errorRecovery/interface-method-protected.src.ts.shot @@ -27,6 +27,7 @@ Object { ], "type": "Identifier", }, + "kind": "method", "loc": Object { "end": Object { "column": 33, diff --git a/packages/typescript-estree/tests/snapshots/typescript/errorRecovery/interface-method-public.src.ts.shot b/packages/typescript-estree/tests/snapshots/typescript/errorRecovery/interface-method-public.src.ts.shot index 5a2b1744960..114bd1a7811 100644 --- a/packages/typescript-estree/tests/snapshots/typescript/errorRecovery/interface-method-public.src.ts.shot +++ b/packages/typescript-estree/tests/snapshots/typescript/errorRecovery/interface-method-public.src.ts.shot @@ -27,6 +27,7 @@ Object { ], "type": "Identifier", }, + "kind": "method", "loc": Object { "end": Object { "column": 32, diff --git a/packages/typescript-estree/tests/snapshots/typescript/errorRecovery/interface-method-readonly.src.ts.shot b/packages/typescript-estree/tests/snapshots/typescript/errorRecovery/interface-method-readonly.src.ts.shot index 521a3a4bcdc..e1a82d8ecda 100644 --- a/packages/typescript-estree/tests/snapshots/typescript/errorRecovery/interface-method-readonly.src.ts.shot +++ b/packages/typescript-estree/tests/snapshots/typescript/errorRecovery/interface-method-readonly.src.ts.shot @@ -26,6 +26,7 @@ Object { ], "type": "Identifier", }, + "kind": "method", "loc": Object { "end": Object { "column": 32, diff --git a/packages/typescript-estree/tests/snapshots/typescript/errorRecovery/interface-method-static.src.ts.shot b/packages/typescript-estree/tests/snapshots/typescript/errorRecovery/interface-method-static.src.ts.shot index bdb4baa843a..8aab33054a9 100644 --- a/packages/typescript-estree/tests/snapshots/typescript/errorRecovery/interface-method-static.src.ts.shot +++ b/packages/typescript-estree/tests/snapshots/typescript/errorRecovery/interface-method-static.src.ts.shot @@ -26,6 +26,7 @@ Object { ], "type": "Identifier", }, + "kind": "method", "loc": Object { "end": Object { "column": 30, diff --git a/packages/typescript-estree/tests/snapshots/typescript/types/interface-with-accessors.src.ts.shot b/packages/typescript-estree/tests/snapshots/typescript/types/interface-with-accessors.src.ts.shot new file mode 100644 index 00000000000..02601964ea1 --- /dev/null +++ b/packages/typescript-estree/tests/snapshots/typescript/types/interface-with-accessors.src.ts.shot @@ -0,0 +1,711 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`typescript types interface-with-accessors.src 1`] = ` +Object { + "body": Array [ + Object { + "body": Object { + "body": Array [ + Object { + "computed": false, + "key": Object { + "loc": Object { + "end": Object { + "column": 10, + "line": 2, + }, + "start": Object { + "column": 6, + "line": 2, + }, + }, + "name": "size", + "range": Array [ + 24, + 28, + ], + "type": "Identifier", + }, + "kind": "get", + "loc": Object { + "end": Object { + "column": 21, + "line": 2, + }, + "start": Object { + "column": 2, + "line": 2, + }, + }, + "params": Array [], + "range": Array [ + 20, + 39, + ], + "returnType": Object { + "loc": Object { + "end": Object { + "column": 20, + "line": 2, + }, + "start": Object { + "column": 12, + "line": 2, + }, + }, + "range": Array [ + 30, + 38, + ], + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 20, + "line": 2, + }, + "start": Object { + "column": 14, + "line": 2, + }, + }, + "range": Array [ + 32, + 38, + ], + "type": "TSNumberKeyword", + }, + }, + "type": "TSMethodSignature", + }, + Object { + "computed": false, + "key": Object { + "loc": Object { + "end": Object { + "column": 10, + "line": 3, + }, + "start": Object { + "column": 6, + "line": 3, + }, + }, + "name": "size", + "range": Array [ + 46, + 50, + ], + "type": "Identifier", + }, + "kind": "set", + "loc": Object { + "end": Object { + "column": 45, + "line": 3, + }, + "start": Object { + "column": 2, + "line": 3, + }, + }, + "params": Array [ + Object { + "loc": Object { + "end": Object { + "column": 43, + "line": 3, + }, + "start": Object { + "column": 11, + "line": 3, + }, + }, + "name": "value", + "range": Array [ + 51, + 83, + ], + "type": "Identifier", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 43, + "line": 3, + }, + "start": Object { + "column": 16, + "line": 3, + }, + }, + "range": Array [ + 56, + 83, + ], + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 43, + "line": 3, + }, + "start": Object { + "column": 18, + "line": 3, + }, + }, + "range": Array [ + 58, + 83, + ], + "type": "TSUnionType", + "types": Array [ + Object { + "loc": Object { + "end": Object { + "column": 24, + "line": 3, + }, + "start": Object { + "column": 18, + "line": 3, + }, + }, + "range": Array [ + 58, + 64, + ], + "type": "TSNumberKeyword", + }, + Object { + "loc": Object { + "end": Object { + "column": 33, + "line": 3, + }, + "start": Object { + "column": 27, + "line": 3, + }, + }, + "range": Array [ + 67, + 73, + ], + "type": "TSStringKeyword", + }, + Object { + "loc": Object { + "end": Object { + "column": 43, + "line": 3, + }, + "start": Object { + "column": 36, + "line": 3, + }, + }, + "range": Array [ + 76, + 83, + ], + "type": "TSBooleanKeyword", + }, + ], + }, + }, + }, + ], + "range": Array [ + 42, + 85, + ], + "type": "TSMethodSignature", + }, + ], + "loc": Object { + "end": Object { + "column": 1, + "line": 4, + }, + "start": Object { + "column": 16, + "line": 1, + }, + }, + "range": Array [ + 16, + 87, + ], + "type": "TSInterfaceBody", + }, + "id": Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 1, + }, + "start": Object { + "column": 10, + "line": 1, + }, + }, + "name": "Thing", + "range": Array [ + 10, + 15, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 1, + "line": 4, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 87, + ], + "type": "TSInterfaceDeclaration", + }, + ], + "comments": Array [], + "loc": Object { + "end": Object { + "column": 0, + "line": 5, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 88, + ], + "sourceType": "script", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 9, + ], + "type": "Keyword", + "value": "interface", + }, + Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 1, + }, + "start": Object { + "column": 10, + "line": 1, + }, + }, + "range": Array [ + 10, + 15, + ], + "type": "Identifier", + "value": "Thing", + }, + Object { + "loc": Object { + "end": Object { + "column": 17, + "line": 1, + }, + "start": Object { + "column": 16, + "line": 1, + }, + }, + "range": Array [ + 16, + 17, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 2, + }, + "start": Object { + "column": 2, + "line": 2, + }, + }, + "range": Array [ + 20, + 23, + ], + "type": "Identifier", + "value": "get", + }, + Object { + "loc": Object { + "end": Object { + "column": 10, + "line": 2, + }, + "start": Object { + "column": 6, + "line": 2, + }, + }, + "range": Array [ + 24, + 28, + ], + "type": "Identifier", + "value": "size", + }, + Object { + "loc": Object { + "end": Object { + "column": 11, + "line": 2, + }, + "start": Object { + "column": 10, + "line": 2, + }, + }, + "range": Array [ + 28, + 29, + ], + "type": "Punctuator", + "value": "(", + }, + Object { + "loc": Object { + "end": Object { + "column": 12, + "line": 2, + }, + "start": Object { + "column": 11, + "line": 2, + }, + }, + "range": Array [ + 29, + 30, + ], + "type": "Punctuator", + "value": ")", + }, + Object { + "loc": Object { + "end": Object { + "column": 13, + "line": 2, + }, + "start": Object { + "column": 12, + "line": 2, + }, + }, + "range": Array [ + 30, + 31, + ], + "type": "Punctuator", + "value": ":", + }, + Object { + "loc": Object { + "end": Object { + "column": 20, + "line": 2, + }, + "start": Object { + "column": 14, + "line": 2, + }, + }, + "range": Array [ + 32, + 38, + ], + "type": "Identifier", + "value": "number", + }, + Object { + "loc": Object { + "end": Object { + "column": 21, + "line": 2, + }, + "start": Object { + "column": 20, + "line": 2, + }, + }, + "range": Array [ + 38, + 39, + ], + "type": "Punctuator", + "value": ";", + }, + Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 3, + }, + "start": Object { + "column": 2, + "line": 3, + }, + }, + "range": Array [ + 42, + 45, + ], + "type": "Identifier", + "value": "set", + }, + Object { + "loc": Object { + "end": Object { + "column": 10, + "line": 3, + }, + "start": Object { + "column": 6, + "line": 3, + }, + }, + "range": Array [ + 46, + 50, + ], + "type": "Identifier", + "value": "size", + }, + Object { + "loc": Object { + "end": Object { + "column": 11, + "line": 3, + }, + "start": Object { + "column": 10, + "line": 3, + }, + }, + "range": Array [ + 50, + 51, + ], + "type": "Punctuator", + "value": "(", + }, + Object { + "loc": Object { + "end": Object { + "column": 16, + "line": 3, + }, + "start": Object { + "column": 11, + "line": 3, + }, + }, + "range": Array [ + 51, + 56, + ], + "type": "Identifier", + "value": "value", + }, + Object { + "loc": Object { + "end": Object { + "column": 17, + "line": 3, + }, + "start": Object { + "column": 16, + "line": 3, + }, + }, + "range": Array [ + 56, + 57, + ], + "type": "Punctuator", + "value": ":", + }, + Object { + "loc": Object { + "end": Object { + "column": 24, + "line": 3, + }, + "start": Object { + "column": 18, + "line": 3, + }, + }, + "range": Array [ + 58, + 64, + ], + "type": "Identifier", + "value": "number", + }, + Object { + "loc": Object { + "end": Object { + "column": 26, + "line": 3, + }, + "start": Object { + "column": 25, + "line": 3, + }, + }, + "range": Array [ + 65, + 66, + ], + "type": "Punctuator", + "value": "|", + }, + Object { + "loc": Object { + "end": Object { + "column": 33, + "line": 3, + }, + "start": Object { + "column": 27, + "line": 3, + }, + }, + "range": Array [ + 67, + 73, + ], + "type": "Identifier", + "value": "string", + }, + Object { + "loc": Object { + "end": Object { + "column": 35, + "line": 3, + }, + "start": Object { + "column": 34, + "line": 3, + }, + }, + "range": Array [ + 74, + 75, + ], + "type": "Punctuator", + "value": "|", + }, + Object { + "loc": Object { + "end": Object { + "column": 43, + "line": 3, + }, + "start": Object { + "column": 36, + "line": 3, + }, + }, + "range": Array [ + 76, + 83, + ], + "type": "Identifier", + "value": "boolean", + }, + Object { + "loc": Object { + "end": Object { + "column": 44, + "line": 3, + }, + "start": Object { + "column": 43, + "line": 3, + }, + }, + "range": Array [ + 83, + 84, + ], + "type": "Punctuator", + "value": ")", + }, + Object { + "loc": Object { + "end": Object { + "column": 45, + "line": 3, + }, + "start": Object { + "column": 44, + "line": 3, + }, + }, + "range": Array [ + 84, + 85, + ], + "type": "Punctuator", + "value": ";", + }, + Object { + "loc": Object { + "end": Object { + "column": 1, + "line": 4, + }, + "start": Object { + "column": 0, + "line": 4, + }, + }, + "range": Array [ + 86, + 87, + ], + "type": "Punctuator", + "value": "}", + }, + ], + "type": "Program", +} +`; diff --git a/packages/typescript-estree/tests/snapshots/typescript/types/object-literal-type-with-accessors.src.ts.shot b/packages/typescript-estree/tests/snapshots/typescript/types/object-literal-type-with-accessors.src.ts.shot new file mode 100644 index 00000000000..df6ae88ba5d --- /dev/null +++ b/packages/typescript-estree/tests/snapshots/typescript/types/object-literal-type-with-accessors.src.ts.shot @@ -0,0 +1,747 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`typescript types object-literal-type-with-accessors.src 1`] = ` +Object { + "body": Array [ + Object { + "id": Object { + "loc": Object { + "end": Object { + "column": 10, + "line": 1, + }, + "start": Object { + "column": 5, + "line": 1, + }, + }, + "name": "Thing", + "range": Array [ + 5, + 10, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 2, + "line": 4, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 85, + ], + "type": "TSTypeAliasDeclaration", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 1, + "line": 4, + }, + "start": Object { + "column": 13, + "line": 1, + }, + }, + "members": Array [ + Object { + "computed": false, + "key": Object { + "loc": Object { + "end": Object { + "column": 10, + "line": 2, + }, + "start": Object { + "column": 6, + "line": 2, + }, + }, + "name": "size", + "range": Array [ + 21, + 25, + ], + "type": "Identifier", + }, + "kind": "get", + "loc": Object { + "end": Object { + "column": 21, + "line": 2, + }, + "start": Object { + "column": 2, + "line": 2, + }, + }, + "params": Array [], + "range": Array [ + 17, + 36, + ], + "returnType": Object { + "loc": Object { + "end": Object { + "column": 20, + "line": 2, + }, + "start": Object { + "column": 12, + "line": 2, + }, + }, + "range": Array [ + 27, + 35, + ], + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 20, + "line": 2, + }, + "start": Object { + "column": 14, + "line": 2, + }, + }, + "range": Array [ + 29, + 35, + ], + "type": "TSNumberKeyword", + }, + }, + "type": "TSMethodSignature", + }, + Object { + "computed": false, + "key": Object { + "loc": Object { + "end": Object { + "column": 10, + "line": 3, + }, + "start": Object { + "column": 6, + "line": 3, + }, + }, + "name": "size", + "range": Array [ + 43, + 47, + ], + "type": "Identifier", + }, + "kind": "set", + "loc": Object { + "end": Object { + "column": 45, + "line": 3, + }, + "start": Object { + "column": 2, + "line": 3, + }, + }, + "params": Array [ + Object { + "loc": Object { + "end": Object { + "column": 43, + "line": 3, + }, + "start": Object { + "column": 11, + "line": 3, + }, + }, + "name": "value", + "range": Array [ + 48, + 80, + ], + "type": "Identifier", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 43, + "line": 3, + }, + "start": Object { + "column": 16, + "line": 3, + }, + }, + "range": Array [ + 53, + 80, + ], + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 43, + "line": 3, + }, + "start": Object { + "column": 18, + "line": 3, + }, + }, + "range": Array [ + 55, + 80, + ], + "type": "TSUnionType", + "types": Array [ + Object { + "loc": Object { + "end": Object { + "column": 24, + "line": 3, + }, + "start": Object { + "column": 18, + "line": 3, + }, + }, + "range": Array [ + 55, + 61, + ], + "type": "TSNumberKeyword", + }, + Object { + "loc": Object { + "end": Object { + "column": 33, + "line": 3, + }, + "start": Object { + "column": 27, + "line": 3, + }, + }, + "range": Array [ + 64, + 70, + ], + "type": "TSStringKeyword", + }, + Object { + "loc": Object { + "end": Object { + "column": 43, + "line": 3, + }, + "start": Object { + "column": 36, + "line": 3, + }, + }, + "range": Array [ + 73, + 80, + ], + "type": "TSBooleanKeyword", + }, + ], + }, + }, + }, + ], + "range": Array [ + 39, + 82, + ], + "type": "TSMethodSignature", + }, + ], + "range": Array [ + 13, + 84, + ], + "type": "TSTypeLiteral", + }, + }, + ], + "comments": Array [], + "loc": Object { + "end": Object { + "column": 0, + "line": 5, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 86, + ], + "sourceType": "script", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 4, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 4, + ], + "type": "Identifier", + "value": "type", + }, + Object { + "loc": Object { + "end": Object { + "column": 10, + "line": 1, + }, + "start": Object { + "column": 5, + "line": 1, + }, + }, + "range": Array [ + 5, + 10, + ], + "type": "Identifier", + "value": "Thing", + }, + Object { + "loc": Object { + "end": Object { + "column": 12, + "line": 1, + }, + "start": Object { + "column": 11, + "line": 1, + }, + }, + "range": Array [ + 11, + 12, + ], + "type": "Punctuator", + "value": "=", + }, + Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 1, + }, + "start": Object { + "column": 13, + "line": 1, + }, + }, + "range": Array [ + 13, + 14, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 2, + }, + "start": Object { + "column": 2, + "line": 2, + }, + }, + "range": Array [ + 17, + 20, + ], + "type": "Identifier", + "value": "get", + }, + Object { + "loc": Object { + "end": Object { + "column": 10, + "line": 2, + }, + "start": Object { + "column": 6, + "line": 2, + }, + }, + "range": Array [ + 21, + 25, + ], + "type": "Identifier", + "value": "size", + }, + Object { + "loc": Object { + "end": Object { + "column": 11, + "line": 2, + }, + "start": Object { + "column": 10, + "line": 2, + }, + }, + "range": Array [ + 25, + 26, + ], + "type": "Punctuator", + "value": "(", + }, + Object { + "loc": Object { + "end": Object { + "column": 12, + "line": 2, + }, + "start": Object { + "column": 11, + "line": 2, + }, + }, + "range": Array [ + 26, + 27, + ], + "type": "Punctuator", + "value": ")", + }, + Object { + "loc": Object { + "end": Object { + "column": 13, + "line": 2, + }, + "start": Object { + "column": 12, + "line": 2, + }, + }, + "range": Array [ + 27, + 28, + ], + "type": "Punctuator", + "value": ":", + }, + Object { + "loc": Object { + "end": Object { + "column": 20, + "line": 2, + }, + "start": Object { + "column": 14, + "line": 2, + }, + }, + "range": Array [ + 29, + 35, + ], + "type": "Identifier", + "value": "number", + }, + Object { + "loc": Object { + "end": Object { + "column": 21, + "line": 2, + }, + "start": Object { + "column": 20, + "line": 2, + }, + }, + "range": Array [ + 35, + 36, + ], + "type": "Punctuator", + "value": ";", + }, + Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 3, + }, + "start": Object { + "column": 2, + "line": 3, + }, + }, + "range": Array [ + 39, + 42, + ], + "type": "Identifier", + "value": "set", + }, + Object { + "loc": Object { + "end": Object { + "column": 10, + "line": 3, + }, + "start": Object { + "column": 6, + "line": 3, + }, + }, + "range": Array [ + 43, + 47, + ], + "type": "Identifier", + "value": "size", + }, + Object { + "loc": Object { + "end": Object { + "column": 11, + "line": 3, + }, + "start": Object { + "column": 10, + "line": 3, + }, + }, + "range": Array [ + 47, + 48, + ], + "type": "Punctuator", + "value": "(", + }, + Object { + "loc": Object { + "end": Object { + "column": 16, + "line": 3, + }, + "start": Object { + "column": 11, + "line": 3, + }, + }, + "range": Array [ + 48, + 53, + ], + "type": "Identifier", + "value": "value", + }, + Object { + "loc": Object { + "end": Object { + "column": 17, + "line": 3, + }, + "start": Object { + "column": 16, + "line": 3, + }, + }, + "range": Array [ + 53, + 54, + ], + "type": "Punctuator", + "value": ":", + }, + Object { + "loc": Object { + "end": Object { + "column": 24, + "line": 3, + }, + "start": Object { + "column": 18, + "line": 3, + }, + }, + "range": Array [ + 55, + 61, + ], + "type": "Identifier", + "value": "number", + }, + Object { + "loc": Object { + "end": Object { + "column": 26, + "line": 3, + }, + "start": Object { + "column": 25, + "line": 3, + }, + }, + "range": Array [ + 62, + 63, + ], + "type": "Punctuator", + "value": "|", + }, + Object { + "loc": Object { + "end": Object { + "column": 33, + "line": 3, + }, + "start": Object { + "column": 27, + "line": 3, + }, + }, + "range": Array [ + 64, + 70, + ], + "type": "Identifier", + "value": "string", + }, + Object { + "loc": Object { + "end": Object { + "column": 35, + "line": 3, + }, + "start": Object { + "column": 34, + "line": 3, + }, + }, + "range": Array [ + 71, + 72, + ], + "type": "Punctuator", + "value": "|", + }, + Object { + "loc": Object { + "end": Object { + "column": 43, + "line": 3, + }, + "start": Object { + "column": 36, + "line": 3, + }, + }, + "range": Array [ + 73, + 80, + ], + "type": "Identifier", + "value": "boolean", + }, + Object { + "loc": Object { + "end": Object { + "column": 44, + "line": 3, + }, + "start": Object { + "column": 43, + "line": 3, + }, + }, + "range": Array [ + 80, + 81, + ], + "type": "Punctuator", + "value": ")", + }, + Object { + "loc": Object { + "end": Object { + "column": 45, + "line": 3, + }, + "start": Object { + "column": 44, + "line": 3, + }, + }, + "range": Array [ + 81, + 82, + ], + "type": "Punctuator", + "value": ";", + }, + Object { + "loc": Object { + "end": Object { + "column": 1, + "line": 4, + }, + "start": Object { + "column": 0, + "line": 4, + }, + }, + "range": Array [ + 83, + 84, + ], + "type": "Punctuator", + "value": "}", + }, + Object { + "loc": Object { + "end": Object { + "column": 2, + "line": 4, + }, + "start": Object { + "column": 1, + "line": 4, + }, + }, + "range": Array [ + 84, + 85, + ], + "type": "Punctuator", + "value": ";", + }, + ], + "type": "Program", +} +`;