-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tsc --build can pass even when there is a problem introduced by a dependency #1067
Comments
For now, perhaps we should use |
I wonder if this overlaps with the caveat in https://www.typescriptlang.org/docs/handbook/project-references.html#caveats. Do we need to make sure noEmitOnError is truly enabled? |
@jonathanolson and I discussed briefly. The next steps for this issue are:
|
Surprisingly, the self-contained example does not exhibit this problem. (Note that it is easier to switch between the tandem being a string vs any). I'm not sure if I have the tsconfigs matching our style exactly, or where the essential difference might be. Multiple layers to get to the dependency? Index: test/typescript/test-dependencies/gravity-and-orbits/tsconfig.json
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/test/typescript/test-dependencies/gravity-and-orbits/tsconfig.json b/test/typescript/test-dependencies/gravity-and-orbits/tsconfig.json
new file mode 100644
--- /dev/null (date 1631312913052)
+++ b/test/typescript/test-dependencies/gravity-and-orbits/tsconfig.json (date 1631312913052)
@@ -0,0 +1,22 @@
+{
+ "references": [
+ {
+ "path": "../tandem"
+ }
+ ],
+ "compilerOptions": {
+ "module": "commonjs",
+ "target": "es5",
+ "sourceMap": true,
+ "composite": true,
+ "outDir": "./dist/",
+ "incremental": true,
+ "allowJs": true
+ },
+ "include": [
+ "GravityAndOrbitsScene.ts"
+ ],
+ "exclude": [
+ "node_modules"
+ ]
+}
\ No newline at end of file
Index: test/typescript/test-dependencies/gravity-and-orbits/GravityAndOrbitsScene.ts
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/test/typescript/test-dependencies/gravity-and-orbits/GravityAndOrbitsScene.ts b/test/typescript/test-dependencies/gravity-and-orbits/GravityAndOrbitsScene.ts
new file mode 100644
--- /dev/null (date 1631313092547)
+++ b/test/typescript/test-dependencies/gravity-and-orbits/GravityAndOrbitsScene.ts (date 1631313092547)
@@ -0,0 +1,9 @@
+// Copyright 2021, University of Colorado Boulder
+import PhetioObject from '../tandem/PhetioObject';
+
+class GravityAndOrbitsScene extends PhetioObject {
+ constructor() {
+ super( {} );
+ this.tandem.runSomething();
+ }
+}
\ No newline at end of file
Index: test/typescript/test-dependencies/tandem/tsconfig.json
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/test/typescript/test-dependencies/tandem/tsconfig.json b/test/typescript/test-dependencies/tandem/tsconfig.json
new file mode 100644
--- /dev/null (date 1631312555500)
+++ b/test/typescript/test-dependencies/tandem/tsconfig.json (date 1631312555500)
@@ -0,0 +1,15 @@
+{
+ "compilerOptions": {
+ "module": "commonjs",
+ "target": "es5",
+ "sourceMap": true,
+ "composite": true,
+ "allowJs": true,
+ "outDir": "./dist/",
+ "incremental": true
+ },
+ "include": ["PhetioObject.js"],
+ "exclude": [
+ "node_modules"
+ ]
+}
\ No newline at end of file
Index: test/typescript/test-dependencies/tandem/PhetioObject.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/test/typescript/test-dependencies/tandem/PhetioObject.js b/test/typescript/test-dependencies/tandem/PhetioObject.js
new file mode 100644
--- /dev/null (date 1631313103943)
+++ b/test/typescript/test-dependencies/tandem/PhetioObject.js (date 1631313103943)
@@ -0,0 +1,16 @@
+// Copyright 2021, University of Colorado Boulder
+const DEFAULTS = {
+
+ tandem: 'optional'
+};
+
+class PhetioObject {
+ constructor( options ) {
+ this.tandem = 'its a tandem';
+
+ // other code
+ // this.tandem = options.tandem;
+ }
+}
+
+export default PhetioObject;
\ No newline at end of file
|
That did the trick. I introduced an intermediate transitive dependency and now can reproduce the problem in an isolated case. I'll show a patch for this failing example, perhaps we can rename it to something sensible for sharing in a TypeScript issue. Index: test/typescript/test-dependencies/gravity-and-orbits/tsconfig.json
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/test/typescript/test-dependencies/gravity-and-orbits/tsconfig.json b/test/typescript/test-dependencies/gravity-and-orbits/tsconfig.json
new file mode 100644
--- /dev/null (date 1631332362009)
+++ b/test/typescript/test-dependencies/gravity-and-orbits/tsconfig.json (date 1631332362009)
@@ -0,0 +1,22 @@
+{
+ "references": [
+ {
+ "path": "../joist"
+ }
+ ],
+ "compilerOptions": {
+ "module": "commonjs",
+ "target": "es5",
+ "sourceMap": true,
+ "composite": true,
+ "outDir": "./dist/",
+ "incremental": true,
+ "allowJs": true
+ },
+ "include": [
+ "GravityAndOrbitsScene.ts"
+ ],
+ "exclude": [
+ "node_modules"
+ ]
+}
\ No newline at end of file
Index: test/typescript/test-dependencies/gravity-and-orbits/GravityAndOrbitsScene.ts
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/test/typescript/test-dependencies/gravity-and-orbits/GravityAndOrbitsScene.ts b/test/typescript/test-dependencies/gravity-and-orbits/GravityAndOrbitsScene.ts
new file mode 100644
--- /dev/null (date 1631332680316)
+++ b/test/typescript/test-dependencies/gravity-and-orbits/GravityAndOrbitsScene.ts (date 1631332680316)
@@ -0,0 +1,9 @@
+// Copyright 2021, University of Colorado Boulder
+import PhetioObject from '../tandem/PhetioObject';
+
+class GravityAndOrbitsScene extends PhetioObject {
+ constructor() {
+ super( {} );
+ this.tandem.runSomething();
+ }
+}
\ No newline at end of file
Index: test/typescript/test-dependencies/tandem/tsconfig.json
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/test/typescript/test-dependencies/tandem/tsconfig.json b/test/typescript/test-dependencies/tandem/tsconfig.json
new file mode 100644
--- /dev/null (date 1631312555500)
+++ b/test/typescript/test-dependencies/tandem/tsconfig.json (date 1631312555500)
@@ -0,0 +1,15 @@
+{
+ "compilerOptions": {
+ "module": "commonjs",
+ "target": "es5",
+ "sourceMap": true,
+ "composite": true,
+ "allowJs": true,
+ "outDir": "./dist/",
+ "incremental": true
+ },
+ "include": ["PhetioObject.js"],
+ "exclude": [
+ "node_modules"
+ ]
+}
\ No newline at end of file
Index: test/typescript/test-dependencies/joist/tsconfig.json
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/test/typescript/test-dependencies/joist/tsconfig.json b/test/typescript/test-dependencies/joist/tsconfig.json
new file mode 100644
--- /dev/null (date 1631332655878)
+++ b/test/typescript/test-dependencies/joist/tsconfig.json (date 1631332655878)
@@ -0,0 +1,19 @@
+{
+ "references": [
+ {
+ "path": "../tandem"
+ }
+ ],
+ "compilerOptions": {
+ "module": "commonjs",
+ "target": "es5",
+ "sourceMap": true,
+ "composite": true,
+ "allowJs": true,
+ "outDir": "./dist/",
+ "incremental": true
+ },
+ "exclude": [
+ "node_modules"
+ ]
+}
\ No newline at end of file
Index: test/typescript/test-dependencies/tandem/PhetioObject.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/test/typescript/test-dependencies/tandem/PhetioObject.js b/test/typescript/test-dependencies/tandem/PhetioObject.js
new file mode 100644
--- /dev/null (date 1631332909359)
+++ b/test/typescript/test-dependencies/tandem/PhetioObject.js (date 1631332909359)
@@ -0,0 +1,9 @@
+// Copyright 2021, University of Colorado Boulder
+class PhetioObject {
+ constructor( options ) {
+ // this.tandem = 'its a tandem';
+ this.tandem = options.tandem;
+ }
+}
+
+export default PhetioObject;
\ No newline at end of file
Instructions:
Note in the last step that Here's a renamed version that uses A,B,C: Index: test/typescript/test-dependencies/projectA/tsconfig.json
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/test/typescript/test-dependencies/projectA/tsconfig.json b/test/typescript/test-dependencies/projectA/tsconfig.json
new file mode 100644
--- /dev/null (date 1631333534010)
+++ b/test/typescript/test-dependencies/projectA/tsconfig.json (date 1631333534010)
@@ -0,0 +1,18 @@
+{
+ "references": [
+ {
+ "path": "../projectB"
+ }
+ ],
+ "compilerOptions": {
+ "module": "commonjs",
+ "target": "es5",
+ "composite": true,
+ "outDir": "./dist/",
+ "incremental": true,
+ "allowJs": true
+ },
+ "include": [
+ "A.ts"
+ ]
+}
\ No newline at end of file
Index: test/typescript/test-dependencies/projectA/A.ts
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/test/typescript/test-dependencies/projectA/A.ts b/test/typescript/test-dependencies/projectA/A.ts
new file mode 100644
--- /dev/null (date 1631333343040)
+++ b/test/typescript/test-dependencies/projectA/A.ts (date 1631333343040)
@@ -0,0 +1,9 @@
+// Copyright 2021, University of Colorado Boulder
+import C from '../projectC/C';
+
+class A extends C {
+ constructor() {
+ super( {} );
+ this.name.arbitraryFakeMethod();
+ }
+}
\ No newline at end of file
Index: test/typescript/test-dependencies/projectC/tsconfig.json
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/test/typescript/test-dependencies/projectC/tsconfig.json b/test/typescript/test-dependencies/projectC/tsconfig.json
new file mode 100644
--- /dev/null (date 1631333534012)
+++ b/test/typescript/test-dependencies/projectC/tsconfig.json (date 1631333534012)
@@ -0,0 +1,11 @@
+{
+ "compilerOptions": {
+ "module": "commonjs",
+ "target": "es5",
+ "composite": true,
+ "allowJs": true,
+ "outDir": "./dist/",
+ "incremental": true
+ },
+ "include": ["C.js"]
+}
\ No newline at end of file
Index: test/typescript/test-dependencies/projectB/tsconfig.json
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/test/typescript/test-dependencies/projectB/tsconfig.json b/test/typescript/test-dependencies/projectB/tsconfig.json
new file mode 100644
--- /dev/null (date 1631333534011)
+++ b/test/typescript/test-dependencies/projectB/tsconfig.json (date 1631333534011)
@@ -0,0 +1,15 @@
+{
+ "references": [
+ {
+ "path": "../projectC"
+ }
+ ],
+ "compilerOptions": {
+ "module": "commonjs",
+ "target": "es5",
+ "composite": true,
+ "allowJs": true,
+ "outDir": "./dist/",
+ "incremental": true
+ }
+}
\ No newline at end of file
Index: test/typescript/test-dependencies/projectC/C.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/test/typescript/test-dependencies/projectC/C.js b/test/typescript/test-dependencies/projectC/C.js
new file mode 100644
--- /dev/null (date 1631333461798)
+++ b/test/typescript/test-dependencies/projectC/C.js (date 1631333461798)
@@ -0,0 +1,9 @@
+// Copyright 2021, University of Colorado Boulder
+class C {
+ constructor( options ) {
+ this.name = 'test name'; // takes type string
+ // this.name = options.name; // infers type any
+ }
+}
+
+export default C;
\ No newline at end of file
Instructions:
Note that switching projectA's tsconfig references to depend on projectC directly instead of through projectB correctly identifies the problem. The same problem occurs if projectC is a *.ts file C.ts instead of C.js (adding the field declaration as appropriate for each test). Next steps:
|
Draft write up before creating a TypeScript issue: Issue title: # tsc -b incorrectly succeeds when there is a problem introduced by a transitive dependency Bug Report
|
@jonathanolson and/or @zepumph can one of you please volunteer to review the prior comment, which is a draft issue to report to TypeScript? You should follow the steps, see if you get the same result. Are the instructions clear? Do you have any ideas about the problem, or can you find any paper trail on it in https://github.com/microsoft/TypeScript/issues ? You can check out different versions of typescript like so: Also, let me know if you prefer to discuss and work through this synchronously. |
The bug report template recommended testing against the nightly build. I ran 3.0.3 has this problem: So this bug was introduced between 3.5.3 and 3.6.0-beta. All releases are listed here: https://www.npmjs.com/package/typescript, so we can binary search: 3.6.0-dev.20190530 (first release in that series) - GOOD So the problem was introduced in 3.6.0-dev.20190622. Looking at the TypeScript commits from that day, there are 3-6 commits that look like they relate to project references. There are no referenced issues in the commit messages. |
Verified #1067 (comment), reproduced the buggy case, directions were quite clear! |
I opened the issue in the TypeScript repo, linked above. On hold while we await a response. |
In the TypeScript issue, the behavior was identified as a bug, and it was labeled for investigation in TypeScript 4.6. Self-unassigning until then. |
We no longer use project references or |
Follow these steps:
(1) in GravityAndOrbitsScene.ts, add a line like:
(2) run tsc -b in gravity-and-orbits, it should fail
(3) Then in PhetioObject.js, comment out
this.tandem=DEFAULTS.tandem
(4) run tsc -b in gravity and orbits, it should succeed since tandem now has
any
type.(5) restore PhetioObject.js
(6) run tsc -b in gravity and orbits, it should fail like it did in step (2) since all of the code is exactly the same, but it succeeds for unknown reasons. Inspecting chipper/dist/PhetioObject.d.ts, it does have the correct type. So it seems that GravityAndOrbitsScene is not getting triggered to recompile. Also, surprisingly,
tsc
succeeds even astsc -b
fails.Running
tsc -b --clean && tsc -b
for each of the 3 compiles correctly shows the missing method. Therefore, it seems there is stale/bad intermediate data from the incremental or project build.The text was updated successfully, but these errors were encountered: