Skip to content
Open
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
3 changes: 2 additions & 1 deletion src/compiler/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4551,7 +4551,7 @@ namespace Parser {
parseExpected(SyntaxKind.OpenParenToken);
const type = parseType();
let attributes: ImportAttributes | undefined;
if (parseOptional(SyntaxKind.CommaToken)) {
if (parseOptional(SyntaxKind.CommaToken) && token() !== SyntaxKind.CloseParenToken) {
const openBracePosition = scanner.getTokenStart();
parseExpected(SyntaxKind.OpenBraceToken);
const currentToken = token();
Expand All @@ -4572,6 +4572,7 @@ namespace Parser {
);
}
}
parseOptional(SyntaxKind.CommaToken);
}
parseExpected(SyntaxKind.CloseParenToken);
const qualifier = parseOptional(SyntaxKind.DotToken) ? parseEntityNameOfTypeReference() : undefined;
Expand Down
12 changes: 12 additions & 0 deletions tests/baselines/reference/typeofImportInvalidElision.errors.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
main.ts(1,39): error TS1005: '{' expected.


==== input.ts (0 errors) ====
export type X = 1;

==== main.ts (1 errors) ====
type T2 = typeof import('./input.js', ,);
~
!!! error TS1005: '{' expected.
!!! related TS1007 main.ts:1:39: The parser expected to find a '}' to match the '{' token here.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This error is... weird. There's no { in the file at all.


13 changes: 13 additions & 0 deletions tests/baselines/reference/typeofImportInvalidElision.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//// [tests/cases/compiler/typeofImportInvalidElision.ts] ////

//// [input.ts]
export type X = 1;

//// [main.ts]
type T2 = typeof import('./input.js', ,);


//// [input.js]
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//// [main.js]
10 changes: 10 additions & 0 deletions tests/baselines/reference/typeofImportInvalidElision.symbols
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
//// [tests/cases/compiler/typeofImportInvalidElision.ts] ////

=== input.ts ===
export type X = 1;
>X : Symbol(X, Decl(input.ts, 0, 0))

=== main.ts ===
type T2 = typeof import('./input.js', ,);
>T2 : Symbol(T2, Decl(main.ts, 0, 0))

12 changes: 12 additions & 0 deletions tests/baselines/reference/typeofImportInvalidElision.types
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//// [tests/cases/compiler/typeofImportInvalidElision.ts] ////

=== input.ts ===
export type X = 1;
>X : 1
> : ^

=== main.ts ===
type T2 = typeof import('./input.js', ,);
>T2 : typeof import("input")
> : ^^^^^^^^^^^^^^^^^^^^^^

14 changes: 14 additions & 0 deletions tests/baselines/reference/typeofImportTrailingCommas.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//// [tests/cases/compiler/typeofImportTrailingCommas.ts] ////

//// [input.ts]
export type X = 1;

//// [main.ts]
type T1 = typeof import('./input.js',)
type T2 = typeof import('./input.js', { with: { "resolution-mode": "import" } },);


//// [input.js]
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//// [main.js]
13 changes: 13 additions & 0 deletions tests/baselines/reference/typeofImportTrailingCommas.symbols
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//// [tests/cases/compiler/typeofImportTrailingCommas.ts] ////

=== input.ts ===
export type X = 1;
>X : Symbol(X, Decl(input.ts, 0, 0))

=== main.ts ===
type T1 = typeof import('./input.js',)
>T1 : Symbol(T1, Decl(main.ts, 0, 0))

type T2 = typeof import('./input.js', { with: { "resolution-mode": "import" } },);
>T2 : Symbol(T2, Decl(main.ts, 0, 38))

16 changes: 16 additions & 0 deletions tests/baselines/reference/typeofImportTrailingCommas.types
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//// [tests/cases/compiler/typeofImportTrailingCommas.ts] ////

=== input.ts ===
export type X = 1;
>X : 1
> : ^

=== main.ts ===
type T1 = typeof import('./input.js',)
>T1 : typeof import("input")
> : ^^^^^^^^^^^^^^^^^^^^^^

type T2 = typeof import('./input.js', { with: { "resolution-mode": "import" } },);
>T2 : typeof import("input")
> : ^^^^^^^^^^^^^^^^^^^^^^

5 changes: 5 additions & 0 deletions tests/cases/compiler/typeofImportInvalidElision.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// @filename: input.ts
export type X = 1;

// @filename: main.ts
type T2 = typeof import('./input.js', ,);
6 changes: 6 additions & 0 deletions tests/cases/compiler/typeofImportTrailingCommas.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// @filename: input.ts
export type X = 1;

// @filename: main.ts
type T1 = typeof import('./input.js',)
type T2 = typeof import('./input.js', { with: { "resolution-mode": "import" } },);