mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-15 03:23:08 -06:00
fix(56376): import type from from "foo" (#56385)
This commit is contained in:
parent
9f15002959
commit
628bf0ec85
@ -7496,6 +7496,11 @@ namespace Parser {
|
||||
function nextTokenIsStringLiteral() {
|
||||
return nextToken() === SyntaxKind.StringLiteral;
|
||||
}
|
||||
|
||||
function nextTokenIsFromKeyword() {
|
||||
return nextToken() === SyntaxKind.FromKeyword;
|
||||
}
|
||||
|
||||
function nextTokenIsIdentifierOrStringLiteralOnSameLine() {
|
||||
nextToken();
|
||||
return !scanner.hasPrecedingLineBreak() && (isIdentifier() || token() === SyntaxKind.StringLiteral);
|
||||
@ -8328,8 +8333,8 @@ namespace Parser {
|
||||
|
||||
let isTypeOnly = false;
|
||||
if (
|
||||
token() !== SyntaxKind.FromKeyword &&
|
||||
identifier?.escapedText === "type" &&
|
||||
(token() !== SyntaxKind.FromKeyword || isIdentifier() && lookAhead(nextTokenIsFromKeyword)) &&
|
||||
(isIdentifier() || tokenAfterImportDefinitelyProducesImportDeclaration())
|
||||
) {
|
||||
isTypeOnly = true;
|
||||
|
||||
21
tests/baselines/reference/importDefaultNamedType2.js
Normal file
21
tests/baselines/reference/importDefaultNamedType2.js
Normal file
@ -0,0 +1,21 @@
|
||||
//// [tests/cases/conformance/externalModules/typeOnly/importDefaultNamedType2.ts] ////
|
||||
|
||||
//// [a.ts]
|
||||
export default class A {}
|
||||
|
||||
//// [b.ts]
|
||||
import type from from './a';
|
||||
|
||||
|
||||
//// [a.js]
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var A = /** @class */ (function () {
|
||||
function A() {
|
||||
}
|
||||
return A;
|
||||
}());
|
||||
exports.default = A;
|
||||
//// [b.js]
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
10
tests/baselines/reference/importDefaultNamedType2.symbols
Normal file
10
tests/baselines/reference/importDefaultNamedType2.symbols
Normal file
@ -0,0 +1,10 @@
|
||||
//// [tests/cases/conformance/externalModules/typeOnly/importDefaultNamedType2.ts] ////
|
||||
|
||||
=== /a.ts ===
|
||||
export default class A {}
|
||||
>A : Symbol(A, Decl(a.ts, 0, 0))
|
||||
|
||||
=== /b.ts ===
|
||||
import type from from './a';
|
||||
>from : Symbol(from, Decl(b.ts, 0, 6))
|
||||
|
||||
10
tests/baselines/reference/importDefaultNamedType2.types
Normal file
10
tests/baselines/reference/importDefaultNamedType2.types
Normal file
@ -0,0 +1,10 @@
|
||||
//// [tests/cases/conformance/externalModules/typeOnly/importDefaultNamedType2.ts] ////
|
||||
|
||||
=== /a.ts ===
|
||||
export default class A {}
|
||||
>A : A
|
||||
|
||||
=== /b.ts ===
|
||||
import type from from './a';
|
||||
>from : from
|
||||
|
||||
@ -0,0 +1,5 @@
|
||||
// @Filename: /a.ts
|
||||
export default class A {}
|
||||
|
||||
// @Filename: /b.ts
|
||||
import type from from './a';
|
||||
Loading…
x
Reference in New Issue
Block a user