Skip to content

Commit 10019fe

Browse files
authored
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
1 parent cae6d7e commit 10019fe

File tree

8 files changed

+78
-15
lines changed

8 files changed

+78
-15
lines changed

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
@@ -47,8 +47,8 @@ public class TaskGenerateTsConfig extends AbstractTaskClientGenerator {
4747
private static final String VERSION = "flow_version";
4848
private static final String ES_TARGET_VERSION = "target";
4949
private static final String TSCONFIG_JSON_OLDER_VERSIONS_TEMPLATE = "tsconfig-%s.json";
50-
private static final String[] vaadinVersions = { "latest", "v23.3.0",
51-
"v23.2", "v23.1", "v22", "v14", "osgi" };
50+
private static final String[] vaadinVersions = { "latest", "v23.3.0.1",
51+
"v23.3.0", "v23.2", "v23.1", "v22", "v14", "osgi" };
5252

5353
//@formatter:off
5454
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 & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,14 @@
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.FileWriter;
2022
import java.io.IOException;
2123
import java.nio.charset.StandardCharsets;
2224
import java.nio.file.Files;
2325
import java.util.Objects;
24-
import java.util.concurrent.atomic.AtomicBoolean;
2526

2627
import org.apache.commons.io.FileUtils;
2728
import org.apache.commons.io.IOUtils;
@@ -32,15 +33,12 @@
3233
import org.junit.rules.TemporaryFolder;
3334
import org.mockito.Mockito;
3435

35-
import com.vaadin.experimental.Feature;
3636
import com.vaadin.experimental.FeatureFlags;
3737
import com.vaadin.flow.di.Lookup;
3838
import com.vaadin.flow.server.ExecutionFailedException;
3939

40-
import static java.nio.charset.StandardCharsets.UTF_8;
41-
4240
public class TaskGenerateTsConfigTest {
43-
static private String LATEST_VERSION = "23.3.0.1";
41+
static private String LATEST_VERSION = "23.3.4";
4442

4543
@Rule
4644
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 & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
package com.vaadin.viteapp;
22

3-
import com.vaadin.flow.component.html.testbench.ParagraphElement;
3+
import org.junit.Assert;
4+
import org.junit.Test;
5+
46
import com.vaadin.flow.testutil.DevToolsElement;
57
import com.vaadin.testbench.TestBenchElement;
68
import com.vaadin.viteapp.views.empty.MainView;
79

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

1312
@Test
@@ -17,6 +16,15 @@ public void applicationStarts() {
1716
header.getText());
1817
}
1918

19+
@Test
20+
public void noTypescriptErrors() throws Exception {
21+
// Ensure the file was loaded
22+
Assert.assertEquals("good", executeScript("return window.bad()"));
23+
Thread.sleep(2000); // Checking is async so it sometimes needs some time
24+
Assert.assertFalse("There should be no error overlay",
25+
$("vite-plugin-checker-error-overlay").exists());
26+
}
27+
2028
@Test
2129
public void imageFromThemeShown() {
2230
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)