Skip to content
This repository was archived by the owner on Jan 14, 2019. It is now read-only.

fix: add missing TSThisType no known nodes #73

Merged
merged 2 commits into from
Jan 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/ast-node-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ export const AST_NODE_TYPES: { [key: string]: string } = {
TSStaticKeyword: 'TSStaticKeyword',
TSStringKeyword: 'TSStringKeyword',
TSSymbolKeyword: 'TSSymbolKeyword',
TSThisType: 'TSThisType',
TSTypeAnnotation: 'TSTypeAnnotation',
TSTypeAliasDeclaration: 'TSTypeAliasDeclaration',
TSTypeLiteral: 'TSTypeLiteral',
Expand Down
3 changes: 2 additions & 1 deletion src/convert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2268,6 +2268,7 @@ export default function convert(config: ConvertConfig): ESTreeNode | null {
break;
}

case SyntaxKind.ThisType:
case SyntaxKind.AnyKeyword:
case SyntaxKind.BigIntKeyword:
case SyntaxKind.BooleanKeyword:
Expand All @@ -2280,7 +2281,7 @@ export default function convert(config: ConvertConfig): ESTreeNode | null {
case SyntaxKind.VoidKeyword:
case SyntaxKind.UndefinedKeyword: {
Object.assign(result, {
type: `TS${SyntaxKind[node.kind]}`
type: AST_NODE_TYPES[`TS${SyntaxKind[node.kind]}`]
});
break;
}
Expand Down
29 changes: 29 additions & 0 deletions tests/fixtures/typescript/types/this-type-expanded.src.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
class A {
public a: number;

public method(this: this): number {
return this.a;
}

public method2(this: A): this {
return this.a;
}

public method3(this: this): number {
var fn = () => this.a;
return fn();
}

public method4(this: A): number {
var fn = () => this.a;
return fn();
}

static staticMethod(this: A): number {
return this.a;
}

static typeof(this: A): this {
return typeof this;
}
}
5 changes: 5 additions & 0 deletions tests/fixtures/typescript/types/this-type.src.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class Message {
clone(): this {
return this;
}
}
4 changes: 4 additions & 0 deletions tests/lib/__snapshots__/semantic-diagnostics-enabled.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -1918,6 +1918,10 @@ exports[`Parse all fixtures with "errorOnTypeScriptSyntaticAndSemanticIssues" en

exports[`Parse all fixtures with "errorOnTypeScriptSyntaticAndSemanticIssues" enabled fixtures/typescript/types/reference-generic-nested.src.ts.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`;

exports[`Parse all fixtures with "errorOnTypeScriptSyntaticAndSemanticIssues" enabled fixtures/typescript/types/this-type.src.ts.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`;

exports[`Parse all fixtures with "errorOnTypeScriptSyntaticAndSemanticIssues" enabled fixtures/typescript/types/this-type-expanded.src.ts.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`;

exports[`Parse all fixtures with "errorOnTypeScriptSyntaticAndSemanticIssues" enabled fixtures/typescript/types/tuple.src.ts.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`;

exports[`Parse all fixtures with "errorOnTypeScriptSyntaticAndSemanticIssues" enabled fixtures/typescript/types/tuple-empty.src.ts.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`;
Expand Down
Loading