Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit92eedcb

Browse files
🤖 Pick PR#61452 (Fix errors on type assertions in er...) into release-5.8 (#61453)
Co-authored-by: Daniel Rosenwasser <DanielRosenwasser@users.noreply.github.com>
1 parent88a002a commit92eedcb

File tree

6 files changed

+87
-2
lines changed

6 files changed

+87
-2
lines changed

‎src/compiler/checker.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37315,8 +37315,8 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
3731537315
grammarErrorOnNode(node, Diagnostics.This_syntax_is_reserved_in_files_with_the_mts_or_cts_extension_Use_an_as_expression_instead);
3731637316
}
3731737317
if (compilerOptions.erasableSyntaxOnly) {
37318-
const start =node.type.pos - "<".length;
37319-
const end =skipTrivia(file.text,node.type.end) + ">".length;
37318+
const start =skipTrivia(file.text, node.pos);
37319+
const end = node.expression.pos;
3732037320
diagnostics.add(createFileDiagnostic(file, start, end - start, Diagnostics.This_syntax_is_not_allowed_when_erasableSyntaxOnly_is_enabled));
3732137321
}
3732237322
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
index.ts(1,10): error TS1294: This syntax is not allowed when 'erasableSyntaxOnly' is enabled.
2+
index.ts(1,19): error TS1005: '>' expected.
3+
index.ts(2,9): error TS1294: This syntax is not allowed when 'erasableSyntaxOnly' is enabled.
4+
index.ts(2,18): error TS1005: '>' expected.
5+
index.ts(3,9): error TS1294: This syntax is not allowed when 'erasableSyntaxOnly' is enabled.
6+
index.ts(3,17): error TS1005: '>' expected.
7+
8+
9+
==== index.ts (6 errors) ====
10+
let a = (<unknown function foo() {});
11+
~~~~~~~~
12+
!!! error TS1294: This syntax is not allowed when 'erasableSyntaxOnly' is enabled.
13+
~~~~~~~~
14+
!!! error TS1005: '>' expected.
15+
let b = <unknown 123;
16+
~~~~~~~~
17+
!!! error TS1294: This syntax is not allowed when 'erasableSyntaxOnly' is enabled.
18+
~~~
19+
!!! error TS1005: '>' expected.
20+
let c = <unknown
21+
~~~~~~~~
22+
!!! error TS1294: This syntax is not allowed when 'erasableSyntaxOnly' is enabled.
23+
24+
!!! error TS1005: '>' expected.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
//// [tests/cases/compiler/erasableSyntaxOnly2.ts] ////
2+
3+
//// [index.ts]
4+
leta=(<unknownfunctionfoo(){});
5+
letb=<unknown123;
6+
letc=<unknown
7+
8+
//// [index.js]
9+
vara=functionfoo(){};
10+
varb=123;
11+
varc=;
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//// [tests/cases/compiler/erasableSyntaxOnly2.ts] ////
2+
3+
=== index.ts ===
4+
let a = (<unknown function foo() {});
5+
>a : Symbol(a, Decl(index.ts, 0, 3))
6+
>foo : Symbol(foo, Decl(index.ts, 0, 17))
7+
8+
let b = <unknown 123;
9+
>b : Symbol(b, Decl(index.ts, 1, 3))
10+
11+
let c = <unknown
12+
>c : Symbol(c, Decl(index.ts, 2, 3))
13+
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
//// [tests/cases/compiler/erasableSyntaxOnly2.ts] ////
2+
3+
=== index.ts ===
4+
let a = (<unknown function foo() {});
5+
>a : unknown
6+
> : ^^^^^^^
7+
>(<unknown function foo() {}) : unknown
8+
> : ^^^^^^^
9+
><unknown function foo() {} : unknown
10+
> : ^^^^^^^
11+
>function foo() {} : () => void
12+
> : ^^^^^^^^^^
13+
>foo : () => void
14+
> : ^^^^^^^^^^
15+
16+
let b = <unknown 123;
17+
>b : unknown
18+
> : ^^^^^^^
19+
><unknown 123 : unknown
20+
> : ^^^^^^^
21+
>123 : 123
22+
> : ^^^
23+
24+
let c = <unknown
25+
>c : unknown
26+
> : ^^^^^^^
27+
><unknown : unknown
28+
> : ^^^^^^^
29+
> : any
30+
> : ^^^
31+
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
//@erasableSyntaxOnly: true
2+
3+
//@filename: index.ts
4+
leta=(<unknownfunctionfoo(){});
5+
letb=<unknown123;
6+
letc=<unknown

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp