mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-12-10 00:20:22 -06:00
Allow line break before import attributes with keyword (#62593)
This commit is contained in:
parent
0b6a241886
commit
d3be7e171b
@ -8435,7 +8435,7 @@ namespace Parser {
|
||||
|
||||
function tryParseImportAttributes() {
|
||||
const currentToken = token();
|
||||
if ((currentToken === SyntaxKind.WithKeyword || currentToken === SyntaxKind.AssertKeyword) && !scanner.hasPrecedingLineBreak()) {
|
||||
if (currentToken === SyntaxKind.WithKeyword || (currentToken === SyntaxKind.AssertKeyword && !scanner.hasPrecedingLineBreak())) {
|
||||
return parseImportAttributes(currentToken);
|
||||
}
|
||||
}
|
||||
|
||||
24
tests/baselines/reference/importAttributes11.symbols
Normal file
24
tests/baselines/reference/importAttributes11.symbols
Normal file
@ -0,0 +1,24 @@
|
||||
//// [tests/cases/conformance/importAttributes/importAttributes11.ts] ////
|
||||
|
||||
=== ./a.json ===
|
||||
{ "key": "value" }
|
||||
>"key" : Symbol("key", Decl(a.json, 0, 1))
|
||||
|
||||
=== ./b.mts ===
|
||||
declare global {
|
||||
>global : Symbol(global, Decl(b.mts, 0, 0))
|
||||
|
||||
interface ImportAttributes {
|
||||
>ImportAttributes : Symbol(ImportAttributes, Decl(lib.es5.d.ts, --, --), Decl(b.mts, 0, 16))
|
||||
|
||||
type: "json"
|
||||
>type : Symbol(ImportAttributes.type, Decl(b.mts, 1, 32))
|
||||
}
|
||||
}
|
||||
|
||||
import a
|
||||
>a : Symbol(a, Decl(b.mts, 6, 6))
|
||||
|
||||
from "./a.json"
|
||||
with {type: "json"}
|
||||
|
||||
31
tests/baselines/reference/importAttributes11.types
Normal file
31
tests/baselines/reference/importAttributes11.types
Normal file
@ -0,0 +1,31 @@
|
||||
//// [tests/cases/conformance/importAttributes/importAttributes11.ts] ////
|
||||
|
||||
=== ./a.json ===
|
||||
{ "key": "value" }
|
||||
>{ "key": "value" } : { key: string; }
|
||||
> : ^^^^^^^^^^^^^^^^
|
||||
>"key" : string
|
||||
> : ^^^^^^
|
||||
>"value" : "value"
|
||||
> : ^^^^^^^
|
||||
|
||||
=== ./b.mts ===
|
||||
declare global {
|
||||
>global : any
|
||||
> : ^^^
|
||||
|
||||
interface ImportAttributes {
|
||||
type: "json"
|
||||
>type : "json"
|
||||
> : ^^^^^^
|
||||
}
|
||||
}
|
||||
|
||||
import a
|
||||
>a : { key: string; }
|
||||
> : ^^^^^^^^^^^^^^^^
|
||||
|
||||
from "./a.json"
|
||||
with {type: "json"}
|
||||
>type : error
|
||||
|
||||
@ -0,0 +1,21 @@
|
||||
// @strict: true
|
||||
// @target: esnext
|
||||
// @module: nodenext
|
||||
// @moduleResolution: nodenext
|
||||
// @noEmit: true
|
||||
|
||||
// https://github.com/microsoft/TypeScript/issues/62590
|
||||
|
||||
// @filename: ./a.json
|
||||
{ "key": "value" }
|
||||
|
||||
// @filename: ./b.mts
|
||||
declare global {
|
||||
interface ImportAttributes {
|
||||
type: "json"
|
||||
}
|
||||
}
|
||||
|
||||
import a
|
||||
from "./a.json"
|
||||
with {type: "json"}
|
||||
Loading…
x
Reference in New Issue
Block a user