Skip to content

Commit be693e9

Browse files
vaadin-botArtur-
andauthored
fix: Do not perform type checking for TS files from jar files (#15700) (CP: 23.3) (#15803)
* fix: Do not perform type checking for TS files from jar files (#15700) The TS files that come from JAR files are not under control of the project developer so enforcing project TS rules on them does not make sense. This is similar to "skipLibCheck" used for TS files that are in node_modules. Fixes #15485 * add import --------- Co-authored-by: Artur <artur@vaadin.com>
1 parent 90e7fa9 commit be693e9

8 files changed

Lines changed: 78 additions & 12 deletions

File tree

‎flow-server/src/main/java/com/vaadin/flow/server/frontend/TaskGenerateTsConfig.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ public class TaskGenerateTsConfig extends AbstractTaskClientGenerator {
4848
private static final String VERSION = "flow_version";
4949
private static final String ES_TARGET_VERSION = "target";
5050
private static final String TSCONFIG_JSON_OLDER_VERSIONS_TEMPLATE = "tsconfig-%s.json";
51-
private static final String[] vaadinVersions = { "latest", "v23.3.0",
52-
"v23.2", "v23.1", "v22", "v14", "osgi" };
51+
private static final String[] vaadinVersions = { "latest", "v23.3.0.1",
52+
"v23.3.0", "v23.2", "v23.1", "v22", "v14", "osgi" };
5353

5454
//@formatter:off
5555
static final String ERROR_MESSAGE =
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// This TypeScript configuration file is generated by vaadin-maven-plugin.
2+
// This is needed for TypeScript compiler to compile your TypeScript code in the project.
3+
// It is recommended to commit this file to the VCS.
4+
// You might want to change the configurations to fit your preferences
5+
// For more information about the configurations, please refer to http://www.typescriptlang.org/docs/handbook/tsconfig-json.html
6+
{
7+
"flow_version": "23.3.0.1",
8+
"compilerOptions": {
9+
"sourceMap": true,
10+
"jsx": "react-jsx",
11+
"inlineSources": true,
12+
"module": "esNext",
13+
"target": "es2020",
14+
"moduleResolution": "node",
15+
"strict": true,
16+
"skipLibCheck": true,
17+
"noFallthroughCasesInSwitch": true,
18+
"noImplicitReturns": true,
19+
"noImplicitAny": true,
20+
"noImplicitThis": true,
21+
"noUnusedLocals": false,
22+
"noUnusedParameters": false,
23+
"experimentalDecorators": true,
24+
"useDefineForClassFields": false,
25+
"baseUrl": "frontend",
26+
"paths": {
27+
"@vaadin/flow-frontend": ["generated/jar-resources"],
28+
"@vaadin/flow-frontend/*": ["generated/jar-resources/*"],
29+
"Frontend/*": ["*"]
30+
}
31+
},
32+
"include": [
33+
"frontend/**/*",
34+
"types.d.ts"
35+
],
36+
"exclude": []
37+
}

‎flow-server/src/main/resources/com/vaadin/flow/server/frontend/tsconfig.json‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// You might want to change the configurations to fit your preferences
55
// For more information about the configurations, please refer to http://www.typescriptlang.org/docs/handbook/tsconfig-json.html
66
{
7-
"flow_version": "23.3.0.1",
7+
"flow_version": "23.3.4",
88
"compilerOptions": {
99
"sourceMap": true,
1010
"jsx": "react-jsx",
@@ -33,5 +33,7 @@
3333
"frontend/**/*",
3434
"types.d.ts"
3535
],
36-
"exclude": []
36+
"exclude": [
37+
"frontend/generated/jar-resources/**"
38+
]
3739
}

‎flow-server/src/test/java/com/vaadin/flow/server/frontend/TaskGenerateTsConfigTest.java‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
*/
1616
package com.vaadin.flow.server.frontend;
1717

18+
import static java.nio.charset.StandardCharsets.UTF_8;
19+
1820
import java.io.File;
1921
import java.io.IOException;
2022
import java.nio.charset.StandardCharsets;
@@ -35,10 +37,8 @@
3537
import com.vaadin.experimental.FeatureFlags;
3638
import com.vaadin.flow.server.ExecutionFailedException;
3739

38-
import static java.nio.charset.StandardCharsets.UTF_8;
39-
4040
public class TaskGenerateTsConfigTest {
41-
static private String LATEST_VERSION = "23.3.0.1";
41+
static private String LATEST_VERSION = "23.3.4";
4242

4343
@Rule
4444
public TemporaryFolder temporaryFolder = new TemporaryFolder();

‎flow-server/src/test/resources/tsconfig-reference.json‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// You might want to change the configurations to fit your preferences
55
// For more information about the configurations, please refer to http://www.typescriptlang.org/docs/handbook/tsconfig-json.html
66
{
7-
"flow_version": "23.3.0.1",
7+
"flow_version": "23.3.4",
88
"compilerOptions": {
99
"sourceMap": true,
1010
"jsx": "react-jsx",
@@ -33,5 +33,7 @@
3333
"frontend/**/*",
3434
"types.d.ts"
3535
],
36-
"exclude": []
36+
"exclude": [
37+
"frontend/generated/jar-resources/**"
38+
]
3739
}

‎flow-tests/test-frontend/vite-basics/src/main/java/com/vaadin/viteapp/views/empty/MainView.java‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
@JsModule("./testscopebuttonloader.js")
2121
@JsModule("./testscopemaploader.js")
2222
@JsModule("./importdir.js")
23+
@JsModule("./bad.ts")
2324
@CssImport(value = "./cssimport-textfield.css", themeFor = "vaadin-text-field")
2425
@CssImport(value = "./cssimport.css")
2526
public class MainView extends Div {

‎flow-tests/test-frontend/vite-basics/src/test/java/com/vaadin/viteapp/BasicsIT.java‎

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
package com.vaadin.viteapp;
22

3+
import org.junit.Assert;
4+
import org.junit.Test;
5+
36
import com.vaadin.flow.component.html.testbench.ParagraphElement;
47
import com.vaadin.flow.testutil.DevToolsElement;
58
import com.vaadin.testbench.TestBenchElement;
69
import com.vaadin.viteapp.views.empty.MainView;
710

8-
import org.junit.Assert;
9-
import org.junit.Test;
10-
1111
public class BasicsIT extends ViteDevModeIT {
1212

1313
@Test
@@ -17,6 +17,15 @@ public void applicationStarts() {
1717
header.getText());
1818
}
1919

20+
@Test
21+
public void noTypescriptErrors() throws Exception {
22+
// Ensure the file was loaded
23+
Assert.assertEquals("good", executeScript("return window.bad()"));
24+
Thread.sleep(2000); // Checking is async so it sometimes needs some time
25+
Assert.assertFalse("There should be no error overlay",
26+
$("vite-plugin-checker-error-overlay").exists());
27+
}
28+
2029
@Test
2130
public void imageFromThemeShown() {
2231
TestBenchElement img = $("img").id(MainView.PLANT);
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
let hello: any; // Must be initialized
2+
3+
function foo(err: any) { // parameter declared but not read
4+
this.emit('end'); // `this` implicitly has type `any`
5+
}
6+
7+
function func1(bar) { // Parameter 'bar' implicitly has an 'any' type.
8+
const baz = "a"; // Local declared but never used
9+
10+
return bar + 'a';
11+
}
12+
13+
(window as any).bad = function() {
14+
return "good";
15+
}

0 commit comments

Comments
 (0)