From 8be72cc6deb59800b27b3664d6e50cafa6542806 Mon Sep 17 00:00:00 2001 From: nojaf Date: Tue, 22 Jul 2025 10:43:08 +0200 Subject: [PATCH 01/14] Mention which package was not found in the build state. --- rescript.json | 4 +++- rewatch/src/build/clean.rs | 7 ++++++- tests/analysis_tests/tests/rescript.json | 2 +- tests/dependencies/rescript-react/rescript.json | 2 +- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/rescript.json b/rescript.json index 0935d87399..d2f60b65c7 100644 --- a/rescript.json +++ b/rescript.json @@ -1,6 +1,8 @@ { "name": "rescript", "bs-dependencies": [ - "@tests/gentype-react-example" + "@tests/gentype-react-example", + "@tests/rescript-react", + "@tests/analysis" ] } \ No newline at end of file diff --git a/rewatch/src/build/clean.rs b/rewatch/src/build/clean.rs index cb7a7db73f..5f01c536e6 100644 --- a/rewatch/src/build/clean.rs +++ b/rewatch/src/build/clean.rs @@ -65,7 +65,12 @@ fn clean_source_files(build_state: &BuildState, root_package: &packages::Package .values() .filter_map(|module| match &module.source_type { SourceType::SourceFile(source_file) => { - let package = build_state.packages.get(&module.package_name).unwrap(); + let package = build_state.packages.get(&module.package_name).unwrap_or_else(|| { + panic!( + "Could not find package for \"{}\" in build state", + &module.package_name + ) + }); Some( root_package .config diff --git a/tests/analysis_tests/tests/rescript.json b/tests/analysis_tests/tests/rescript.json index 731b10efe2..7fa3535e6f 100644 --- a/tests/analysis_tests/tests/rescript.json +++ b/tests/analysis_tests/tests/rescript.json @@ -1,5 +1,5 @@ { - "name": "test", + "name": "@tests/analysis", "reanalyze": { "analysis": ["dce"] }, diff --git a/tests/dependencies/rescript-react/rescript.json b/tests/dependencies/rescript-react/rescript.json index e1339a2b05..c36382c893 100644 --- a/tests/dependencies/rescript-react/rescript.json +++ b/tests/dependencies/rescript-react/rescript.json @@ -1,5 +1,5 @@ { - "name": "@rescript/react", + "name": "@tests/rescript-react", "jsx": { "version": 4, "mode": "classic" From ad6e0c99b3188d17d0669d133a3f2541ead50325 Mon Sep 17 00:00:00 2001 From: nojaf Date: Tue, 22 Jul 2025 10:50:53 +0200 Subject: [PATCH 02/14] Add more meaningful error when rescript.json is not found. --- rewatch/src/build/clean.rs | 2 +- rewatch/src/build/packages.rs | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/rewatch/src/build/clean.rs b/rewatch/src/build/clean.rs index 5f01c536e6..10ff053e28 100644 --- a/rewatch/src/build/clean.rs +++ b/rewatch/src/build/clean.rs @@ -67,7 +67,7 @@ fn clean_source_files(build_state: &BuildState, root_package: &packages::Package SourceType::SourceFile(source_file) => { let package = build_state.packages.get(&module.package_name).unwrap_or_else(|| { panic!( - "Could not find package for \"{}\" in build state", + "Could not find package for \"{}\" in build state.\nMaybe you forgot to add the relative path to your root rescript.config.json file?", &module.package_name ) }); diff --git a/rewatch/src/build/packages.rs b/rewatch/src/build/packages.rs index d01baf3622..17b06523bb 100644 --- a/rewatch/src/build/packages.rs +++ b/rewatch/src/build/packages.rs @@ -244,8 +244,13 @@ pub fn read_config(package_dir: &Path) -> Result { if Path::new(&rescript_json_path).exists() { config::Config::new(&rescript_json_path) - } else { + } else if Path::new(&bsconfig_json_path).exists() { config::Config::new(&bsconfig_json_path) + } else { + Err(anyhow!( + "Could not find rescript.json or bsconfig.json in package directory: {}", + package_dir.to_string_lossy() + )) } } From cfcdcea27c87083c401b321afcc7d75e3480b80c Mon Sep 17 00:00:00 2001 From: nojaf Date: Tue, 22 Jul 2025 10:51:08 +0200 Subject: [PATCH 03/14] Pass correct path to root for clean --- tests/analysis_tests/tests/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/analysis_tests/tests/package.json b/tests/analysis_tests/tests/package.json index 601884c23c..fe25ddfe97 100644 --- a/tests/analysis_tests/tests/package.json +++ b/tests/analysis_tests/tests/package.json @@ -3,7 +3,7 @@ "private": true, "scripts": { "build": "rescript legacy build", - "clean": "rescript clean" + "clean": "rescript clean ../../.." }, "dependencies": { "@rescript/react": "link:../../dependencies/rescript-react", From 7f1b6f572110b817851e837bf7b46178e8a8e70f Mon Sep 17 00:00:00 2001 From: nojaf Date: Tue, 22 Jul 2025 10:53:12 +0200 Subject: [PATCH 04/14] Correct names in rescript.json --- rescript.json | 4 +++- .../analysis_tests/tests-generic-jsx-transform/rescript.json | 2 +- tests/analysis_tests/tests-reanalyze/deadcode/rescript.json | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/rescript.json b/rescript.json index d2f60b65c7..a8305d17fb 100644 --- a/rescript.json +++ b/rescript.json @@ -3,6 +3,8 @@ "bs-dependencies": [ "@tests/gentype-react-example", "@tests/rescript-react", - "@tests/analysis" + "@tests/analysis", + "@tests/generic-jsx-transform", + "@tests/reanalyze-deadcode" ] } \ No newline at end of file diff --git a/tests/analysis_tests/tests-generic-jsx-transform/rescript.json b/tests/analysis_tests/tests-generic-jsx-transform/rescript.json index 22fafc0470..d64415732b 100644 --- a/tests/analysis_tests/tests-generic-jsx-transform/rescript.json +++ b/tests/analysis_tests/tests-generic-jsx-transform/rescript.json @@ -1,5 +1,5 @@ { - "name": "test-generic-jsx-transform", + "name": "@tests/generic-jsx-transform", "sources": [ { "dir": "src", diff --git a/tests/analysis_tests/tests-reanalyze/deadcode/rescript.json b/tests/analysis_tests/tests-reanalyze/deadcode/rescript.json index dcab003eca..8ae5393d1f 100644 --- a/tests/analysis_tests/tests-reanalyze/deadcode/rescript.json +++ b/tests/analysis_tests/tests-reanalyze/deadcode/rescript.json @@ -5,7 +5,7 @@ "unsuppress": [], "transitive": true }, - "name": "sample-typescript-app", + "name": "@tests/reanalyze-deadcode", "jsx": { "version": 4 }, "bs-dependencies": ["@rescript/react"], "sources": [ From 29165b86572bed015e892a81f7ac3fb114c3bab6 Mon Sep 17 00:00:00 2001 From: nojaf Date: Tue, 22 Jul 2025 11:03:18 +0200 Subject: [PATCH 05/14] Do some more name corrections --- rescript.json | 4 ++- .../tests-reanalyze/deadcode/package.json | 2 +- tests/analysis_tests/tests/package.json | 2 +- yarn.lock | 28 +++++++++---------- 4 files changed, 19 insertions(+), 17 deletions(-) diff --git a/rescript.json b/rescript.json index a8305d17fb..411a605ace 100644 --- a/rescript.json +++ b/rescript.json @@ -5,6 +5,8 @@ "@tests/rescript-react", "@tests/analysis", "@tests/generic-jsx-transform", - "@tests/reanalyze-deadcode" + "@tests/reanalyze-deadcode", + "@tests/incremental-typechecking", + "@tests/reanalyze-termination" ] } \ No newline at end of file diff --git a/tests/analysis_tests/tests-reanalyze/deadcode/package.json b/tests/analysis_tests/tests-reanalyze/deadcode/package.json index a73dcaf9bc..16e2563615 100644 --- a/tests/analysis_tests/tests-reanalyze/deadcode/package.json +++ b/tests/analysis_tests/tests-reanalyze/deadcode/package.json @@ -6,7 +6,7 @@ "clean": "rescript clean" }, "dependencies": { - "@rescript/react": "link:../../../dependencies/rescript-react", + "@tests/rescript-react": "link:../../../dependencies/rescript-react", "rescript": "workspace:^" } } diff --git a/tests/analysis_tests/tests/package.json b/tests/analysis_tests/tests/package.json index fe25ddfe97..d72585d469 100644 --- a/tests/analysis_tests/tests/package.json +++ b/tests/analysis_tests/tests/package.json @@ -6,7 +6,7 @@ "clean": "rescript clean ../../.." }, "dependencies": { - "@rescript/react": "link:../../dependencies/rescript-react", + "@tests/rescript-react": "link:../../dependencies/rescript-react", "rescript": "workspace:^" } } diff --git a/yarn.lock b/yarn.lock index 7252b6809e..fb225c6e16 100644 --- a/yarn.lock +++ b/yarn.lock @@ -412,18 +412,6 @@ __metadata: languageName: unknown linkType: soft -"@rescript/react@link:../../../dependencies/rescript-react::locator=%40tests%2Freanalyze-deadcode%40workspace%3Atests%2Fanalysis_tests%2Ftests-reanalyze%2Fdeadcode": - version: 0.0.0-use.local - resolution: "@rescript/react@link:../../../dependencies/rescript-react::locator=%40tests%2Freanalyze-deadcode%40workspace%3Atests%2Fanalysis_tests%2Ftests-reanalyze%2Fdeadcode" - languageName: node - linkType: soft - -"@rescript/react@link:../../dependencies/rescript-react::locator=%40tests%2Fanalysis%40workspace%3Atests%2Fanalysis_tests%2Ftests": - version: 0.0.0-use.local - resolution: "@rescript/react@link:../../dependencies/rescript-react::locator=%40tests%2Fanalysis%40workspace%3Atests%2Fanalysis_tests%2Ftests" - languageName: node - linkType: soft - "@rescript/react@link:../dependencies/rescript-react::locator=%40tests%2Fdocstring-tests%40workspace%3Atests%2Fdocstring_tests": version: 0.0.0-use.local resolution: "@rescript/react@link:../dependencies/rescript-react::locator=%40tests%2Fdocstring-tests%40workspace%3Atests%2Fdocstring_tests" @@ -636,7 +624,7 @@ __metadata: version: 0.0.0-use.local resolution: "@tests/analysis@workspace:tests/analysis_tests/tests" dependencies: - "@rescript/react": "link:../../dependencies/rescript-react" + "@tests/rescript-react": "link:../../dependencies/rescript-react" rescript: "workspace:^" languageName: unknown linkType: soft @@ -685,7 +673,7 @@ __metadata: version: 0.0.0-use.local resolution: "@tests/reanalyze-deadcode@workspace:tests/analysis_tests/tests-reanalyze/deadcode" dependencies: - "@rescript/react": "link:../../../dependencies/rescript-react" + "@tests/rescript-react": "link:../../../dependencies/rescript-react" rescript: "workspace:^" languageName: unknown linkType: soft @@ -698,6 +686,18 @@ __metadata: languageName: unknown linkType: soft +"@tests/rescript-react@link:../../../dependencies/rescript-react::locator=%40tests%2Freanalyze-deadcode%40workspace%3Atests%2Fanalysis_tests%2Ftests-reanalyze%2Fdeadcode": + version: 0.0.0-use.local + resolution: "@tests/rescript-react@link:../../../dependencies/rescript-react::locator=%40tests%2Freanalyze-deadcode%40workspace%3Atests%2Fanalysis_tests%2Ftests-reanalyze%2Fdeadcode" + languageName: node + linkType: soft + +"@tests/rescript-react@link:../../dependencies/rescript-react::locator=%40tests%2Fanalysis%40workspace%3Atests%2Fanalysis_tests%2Ftests": + version: 0.0.0-use.local + resolution: "@tests/rescript-react@link:../../dependencies/rescript-react::locator=%40tests%2Fanalysis%40workspace%3Atests%2Fanalysis_tests%2Ftests" + languageName: node + linkType: soft + "@tests/rescript-react@workspace:tests/dependencies/rescript-react": version: 0.0.0-use.local resolution: "@tests/rescript-react@workspace:tests/dependencies/rescript-react" From fe18ccfbf324a2c2ef9dd08faa1d97c251604234 Mon Sep 17 00:00:00 2001 From: nojaf Date: Tue, 22 Jul 2025 12:06:28 +0200 Subject: [PATCH 06/14] Moar changes --- rescript.json | 3 +- .../rescript.json | 2 +- .../src/ConstructorCompletion__Json.res | 4 +- .../src/ConstructorCompletion__Own.res | 4 +- .../tests-reanalyze/deadcode/rescript.json | 2 +- .../src/exception/ExportWithRename.res | 2 - .../tests-reanalyze/termination/rescript.json | 2 +- tests/analysis_tests/tests/rescript.json | 2 +- .../typescript-react-example/rescript.json | 2 +- .../src/nested/NestedTuples.gen.tsx | 32 +++++ .../src/nested/NestedTuples.js | 67 +++++++++ .../nested/{Tuples.res => NestedTuples.res} | 0 .../src/nested/NestedTypes.gen.tsx | 135 ++++++++++++++++++ .../src/nested/NestedTypes.js | 102 +++++++++++++ .../src/nested/{Types.res => NestedTypes.res} | 0 15 files changed, 347 insertions(+), 12 deletions(-) delete mode 100644 tests/analysis_tests/tests-reanalyze/deadcode/src/exception/ExportWithRename.res create mode 100644 tests/gentype_tests/typescript-react-example/src/nested/NestedTuples.gen.tsx create mode 100644 tests/gentype_tests/typescript-react-example/src/nested/NestedTuples.js rename tests/gentype_tests/typescript-react-example/src/nested/{Tuples.res => NestedTuples.res} (100%) create mode 100644 tests/gentype_tests/typescript-react-example/src/nested/NestedTypes.gen.tsx create mode 100644 tests/gentype_tests/typescript-react-example/src/nested/NestedTypes.js rename tests/gentype_tests/typescript-react-example/src/nested/{Types.res => NestedTypes.res} (100%) diff --git a/rescript.json b/rescript.json index 411a605ace..fb5b7c5624 100644 --- a/rescript.json +++ b/rescript.json @@ -8,5 +8,6 @@ "@tests/reanalyze-deadcode", "@tests/incremental-typechecking", "@tests/reanalyze-termination" - ] + ], + "jsx": { "version": 4 } } \ No newline at end of file diff --git a/tests/analysis_tests/tests-incremental-typechecking/rescript.json b/tests/analysis_tests/tests-incremental-typechecking/rescript.json index 22fafc0470..6a3277b934 100644 --- a/tests/analysis_tests/tests-incremental-typechecking/rescript.json +++ b/tests/analysis_tests/tests-incremental-typechecking/rescript.json @@ -1,5 +1,5 @@ { - "name": "test-generic-jsx-transform", + "name": "@tests/incremental-typechecking", "sources": [ { "dir": "src", diff --git a/tests/analysis_tests/tests-incremental-typechecking/src/ConstructorCompletion__Json.res b/tests/analysis_tests/tests-incremental-typechecking/src/ConstructorCompletion__Json.res index 5173fefec0..4ce646d97d 100644 --- a/tests/analysis_tests/tests-incremental-typechecking/src/ConstructorCompletion__Json.res +++ b/tests/analysis_tests/tests-incremental-typechecking/src/ConstructorCompletion__Json.res @@ -1,2 +1,2 @@ -let x = Js.Json.Array() -// ^com +// let x = Js.Json.Array() +// ^com diff --git a/tests/analysis_tests/tests-incremental-typechecking/src/ConstructorCompletion__Own.res b/tests/analysis_tests/tests-incremental-typechecking/src/ConstructorCompletion__Own.res index b77e1f4ec6..3320609748 100644 --- a/tests/analysis_tests/tests-incremental-typechecking/src/ConstructorCompletion__Own.res +++ b/tests/analysis_tests/tests-incremental-typechecking/src/ConstructorCompletion__Own.res @@ -2,5 +2,5 @@ module WithVariant = { type t = One({miss: bool}) | Two(bool) } -let x = WithVariant.One() -// ^com +// let x = WithVariant.One() +// ^com diff --git a/tests/analysis_tests/tests-reanalyze/deadcode/rescript.json b/tests/analysis_tests/tests-reanalyze/deadcode/rescript.json index 8ae5393d1f..aab7ac66ee 100644 --- a/tests/analysis_tests/tests-reanalyze/deadcode/rescript.json +++ b/tests/analysis_tests/tests-reanalyze/deadcode/rescript.json @@ -7,7 +7,7 @@ }, "name": "@tests/reanalyze-deadcode", "jsx": { "version": 4 }, - "bs-dependencies": ["@rescript/react"], + "bs-dependencies": ["@tests/rescript-react"], "sources": [ { "dir": "src", diff --git a/tests/analysis_tests/tests-reanalyze/deadcode/src/exception/ExportWithRename.res b/tests/analysis_tests/tests-reanalyze/deadcode/src/exception/ExportWithRename.res deleted file mode 100644 index b8b4865b2a..0000000000 --- a/tests/analysis_tests/tests-reanalyze/deadcode/src/exception/ExportWithRename.res +++ /dev/null @@ -1,2 +0,0 @@ -@genType("ExportWithRename") @react.component -let make = (~s) => React.string(s) diff --git a/tests/analysis_tests/tests-reanalyze/termination/rescript.json b/tests/analysis_tests/tests-reanalyze/termination/rescript.json index c1a2690d9d..b6de84f040 100644 --- a/tests/analysis_tests/tests-reanalyze/termination/rescript.json +++ b/tests/analysis_tests/tests-reanalyze/termination/rescript.json @@ -4,7 +4,7 @@ "suppress": [], "unsuppress": [] }, - "name": "arnold", + "name": "@tests/reanalyze-termination", "bs-dependencies": [], "sources": [ { diff --git a/tests/analysis_tests/tests/rescript.json b/tests/analysis_tests/tests/rescript.json index 7fa3535e6f..52dfae35fc 100644 --- a/tests/analysis_tests/tests/rescript.json +++ b/tests/analysis_tests/tests/rescript.json @@ -10,7 +10,7 @@ } ], "bsc-flags": ["-w -33-44-8"], - "bs-dependencies": ["@rescript/react"], + "bs-dependencies": ["@tests/rescript-react"], "jsx": { "version": 4 }, "suffix": ".res.js", "editor": { diff --git a/tests/gentype_tests/typescript-react-example/rescript.json b/tests/gentype_tests/typescript-react-example/rescript.json index 60f5f49259..a1f1f76af2 100644 --- a/tests/gentype_tests/typescript-react-example/rescript.json +++ b/tests/gentype_tests/typescript-react-example/rescript.json @@ -18,7 +18,7 @@ "name": "@tests/gentype-react-example", "bsc-flags": [], "jsx": { "version": 4 }, - "bs-dependencies": ["@rescript/react"], + "bs-dependencies": ["@tests/rescript-react"], "sources": [ { "dir": "src", diff --git a/tests/gentype_tests/typescript-react-example/src/nested/NestedTuples.gen.tsx b/tests/gentype_tests/typescript-react-example/src/nested/NestedTuples.gen.tsx new file mode 100644 index 0000000000..be4d0f07a7 --- /dev/null +++ b/tests/gentype_tests/typescript-react-example/src/nested/NestedTuples.gen.tsx @@ -0,0 +1,32 @@ +/* TypeScript file generated from NestedTuples.res by genType. */ + +/* eslint-disable */ +/* tslint:disable */ + +import * as NestedTuplesJS from './NestedTuples.res.js'; + +export type coord = [number, number, (undefined | number)]; + +export type coord2 = [number, number, (null | undefined | number)]; + +export type person = { readonly name: string; readonly age: number }; + +export type couple = [person, person]; + +export const testTuple: (param:[number, number]) => number = NestedTuplesJS.testTuple as any; + +export const origin: [number, number, (undefined | number)] = NestedTuplesJS.origin as any; + +export const computeArea: (param:[number, number, (undefined | number)]) => number = NestedTuplesJS.computeArea as any; + +export const computeAreaWithIdent: (param:coord) => number = NestedTuplesJS.computeAreaWithIdent as any; + +export const computeAreaNoConverters: (param:[number, number]) => number = NestedTuplesJS.computeAreaNoConverters as any; + +export const coord2d: (x:T1, y:T2) => [T1, T2, (undefined | T3)] = NestedTuplesJS.coord2d as any; + +export const getFirstName: (param:couple) => string = NestedTuplesJS.getFirstName as any; + +export const marry: (first:person, second:person) => couple = NestedTuplesJS.marry as any; + +export const changeSecondAge: (param:couple) => couple = NestedTuplesJS.changeSecondAge as any; diff --git a/tests/gentype_tests/typescript-react-example/src/nested/NestedTuples.js b/tests/gentype_tests/typescript-react-example/src/nested/NestedTuples.js new file mode 100644 index 0000000000..b3d6bb405d --- /dev/null +++ b/tests/gentype_tests/typescript-react-example/src/nested/NestedTuples.js @@ -0,0 +1,67 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE +'use strict'; + +let Belt_Option = require("rescript/lib/js/Belt_Option.js"); + +function testTuple(param) { + return param[0] + param[1] | 0; +} + +function computeArea(param) { + return (param[0] * param[1] | 0) * Belt_Option.mapWithDefault(param[2], 1, n => n) | 0; +} + +function computeAreaWithIdent(param) { + return (param[0] * param[1] | 0) * Belt_Option.mapWithDefault(param[2], 1, n => n) | 0; +} + +function computeAreaNoConverters(param) { + return param[0] * param[1] | 0; +} + +function coord2d(x, y) { + return [ + x, + y, + undefined + ]; +} + +function getFirstName(param) { + return param[0].name; +} + +function marry(first, second) { + return [ + first, + second + ]; +} + +function changeSecondAge(param) { + let second = param[1]; + return [ + param[0], + { + name: second.name, + age: second.age + 1 | 0 + } + ]; +} + +let origin = [ + 0, + 0, + 0 +]; + +exports.testTuple = testTuple; +exports.origin = origin; +exports.computeArea = computeArea; +exports.computeAreaWithIdent = computeAreaWithIdent; +exports.computeAreaNoConverters = computeAreaNoConverters; +exports.coord2d = coord2d; +exports.getFirstName = getFirstName; +exports.marry = marry; +exports.changeSecondAge = changeSecondAge; +/* No side effect */ diff --git a/tests/gentype_tests/typescript-react-example/src/nested/Tuples.res b/tests/gentype_tests/typescript-react-example/src/nested/NestedTuples.res similarity index 100% rename from tests/gentype_tests/typescript-react-example/src/nested/Tuples.res rename to tests/gentype_tests/typescript-react-example/src/nested/NestedTuples.res diff --git a/tests/gentype_tests/typescript-react-example/src/nested/NestedTypes.gen.tsx b/tests/gentype_tests/typescript-react-example/src/nested/NestedTypes.gen.tsx new file mode 100644 index 0000000000..4caba94a76 --- /dev/null +++ b/tests/gentype_tests/typescript-react-example/src/nested/NestedTypes.gen.tsx @@ -0,0 +1,135 @@ +/* TypeScript file generated from NestedTypes.res by genType. */ + +/* eslint-disable */ +/* tslint:disable */ + +import * as NestedTypesJS from './NestedTypes.res.js'; + +import type {Json_t as Js_Json_t} from '../../src/shims/Js.shim'; + +import type {List_t as Belt_List_t} from '../../src/shims/Belt.shim'; + +import type {M_t__ as TypeNameSanitize_M_t__} from '../../src/TypeNameSanitize.gen'; + +import type {list} from '../../src/shims/RescriptPervasives.shim'; + +import type {t_ as TypeNameSanitize_t_} from '../../src/TypeNameSanitize.gen'; + +import type {t as Location_t} from '../../src/location/location.gen'; + +export type t = number; + +export type typeWithVars = + { TAG: "A"; _0: x; _1: y } + | { TAG: "B"; _0: z }; + +export type tree = { + readonly label: string; + readonly left?: tree; + readonly right?: tree +}; + +export type selfRecursive = { readonly self: selfRecursive }; + +export type mutuallyRecursiveA = { readonly b: mutuallyRecursiveB }; + +export type mutuallyRecursiveB = { readonly a: mutuallyRecursiveA }; + +export abstract class opaqueVariant { protected opaque!: any }; /* simulate opaque types */ + +export type twice = [a, a]; + +export type genTypeMispelled = number; + +export type dictString = {[id: string]: string}; + +export type nullOrString = (null | string); + +export type nullOrString2 = (null | string); + +export type nullOrString3 = (null | string); + +export type nullOrString4 = (null | string); + +export type nullableOrString = (null | undefined | string); + +export type nullableOrString2 = (null | undefined | string); + +export type nullableOrString3 = (null | undefined | string); + +export type nullableOrString4 = (null | undefined | string); + +export type undefinedOrString = (undefined | string); + +export type undefinedOrString2 = (undefined | string); + +export type undefinedOrString3 = (undefined | string); + +export type undefinedOrString4 = (undefined | string); + +export type record = { readonly i: number; readonly s: string }; + +export type decorator = (_1:a) => b; + +export type marshalFields = { + readonly _rec: string; + readonly _switch: string; + readonly switch: string; + readonly __: string; + readonly ___: string; + readonly foo__: string; + readonly _foo__: string; + readonly _Uppercase: string; + readonly _Uppercase__: string +}; + +export type marshalMutableField = { _match: number }; + +export type ocaml_array = a[]; + +export type someRecord = { readonly id: number }; + +export type instantiateTypeParameter = ocaml_array; + +export type vector = [a, a]; +export type Vector = vector; + +export type date = Date; + +export type ObjectId_t = number; + +export type tPrimed = [TypeNameSanitize_t_, TypeNameSanitize_M_t__]; + +export const someIntList: list = NestedTypesJS.someIntList as any; + +export const map: (_1:Belt_List_t, _2:((_1:T1) => T2)) => Belt_List_t = NestedTypesJS.map as any; + +export const swap: (tree:tree) => tree = NestedTypesJS.swap as any; + +export const selfRecursiveConverter: (param:selfRecursive) => selfRecursive = NestedTypesJS.selfRecursiveConverter as any; + +export const mutuallyRecursiveConverter: (param:mutuallyRecursiveA) => mutuallyRecursiveB = NestedTypesJS.mutuallyRecursiveConverter as any; + +export const testFunctionOnOptionsAsArgument: (a:(undefined | a), foo:((_1:(undefined | a)) => T1)) => T1 = NestedTypesJS.testFunctionOnOptionsAsArgument as any; + +export const stringT: string = NestedTypesJS.stringT as any; + +export const jsStringT: string = NestedTypesJS.jsStringT as any; + +export const jsString2T: string = NestedTypesJS.jsString2T as any; + +export const jsonStringify: (_1:Js_Json_t) => string = NestedTypesJS.jsonStringify as any; + +export const testConvertNull: (x:(null | record)) => (null | record) = NestedTypesJS.testConvertNull as any; + +export const testConvertLocation: (x:Location_t) => Location_t = NestedTypesJS.testConvertLocation as any; + +export const testMarshalFields: marshalFields = NestedTypesJS.testMarshalFields as any; + +export const setMatch: (x:marshalMutableField) => void = NestedTypesJS.setMatch as any; + +export const testInstantiateTypeParameter: (x:instantiateTypeParameter) => instantiateTypeParameter = NestedTypesJS.testInstantiateTypeParameter as any; + +export const currentTime: Date = NestedTypesJS.currentTime as any; + +export const optFunction: (undefined | (() => number)) = NestedTypesJS.optFunction as any; diff --git a/tests/gentype_tests/typescript-react-example/src/nested/NestedTypes.js b/tests/gentype_tests/typescript-react-example/src/nested/NestedTypes.js new file mode 100644 index 0000000000..219b6fe6fb --- /dev/null +++ b/tests/gentype_tests/typescript-react-example/src/nested/NestedTypes.js @@ -0,0 +1,102 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE +'use strict'; + +let Belt_List = require("rescript/lib/js/Belt_List.js"); +let Belt_Option = require("rescript/lib/js/Belt_Option.js"); + +function swap(tree) { + return { + label: tree.label, + left: Belt_Option.map(tree.right, swap), + right: Belt_Option.map(tree.left, swap) + }; +} + +function selfRecursiveConverter(param) { + return param.self; +} + +function mutuallyRecursiveConverter(param) { + return param.b; +} + +function testFunctionOnOptionsAsArgument(a, foo) { + return foo(a); +} + +function jsonStringify(prim) { + return JSON.stringify(prim); +} + +function testConvertNull(x) { + return x; +} + +function testConvertLocation(x) { + return x; +} + +let testMarshalFields = { + _rec: "rec", + _switch: "_switch", + switch: "switch", + __: "__", + ___: "_", + foo__: "foo", + _foo__: "_foo", + _Uppercase: "Uppercase", + _Uppercase__: "_Uppercase" +}; + +function setMatch(x) { + x._match = 34; +} + +function testInstantiateTypeParameter(x) { + return x; +} + +let currentTime = new Date(); + +let optFunction = () => 3; + +let ObjectId = {}; + +let someIntList = { + hd: 1, + tl: { + hd: 2, + tl: { + hd: 3, + tl: /* [] */0 + } + } +}; + +let map = Belt_List.map; + +let stringT = "a"; + +let jsStringT = "a"; + +let jsString2T = "a"; + +exports.someIntList = someIntList; +exports.map = map; +exports.swap = swap; +exports.selfRecursiveConverter = selfRecursiveConverter; +exports.mutuallyRecursiveConverter = mutuallyRecursiveConverter; +exports.testFunctionOnOptionsAsArgument = testFunctionOnOptionsAsArgument; +exports.stringT = stringT; +exports.jsStringT = jsStringT; +exports.jsString2T = jsString2T; +exports.jsonStringify = jsonStringify; +exports.testConvertNull = testConvertNull; +exports.testConvertLocation = testConvertLocation; +exports.testMarshalFields = testMarshalFields; +exports.setMatch = setMatch; +exports.testInstantiateTypeParameter = testInstantiateTypeParameter; +exports.currentTime = currentTime; +exports.optFunction = optFunction; +exports.ObjectId = ObjectId; +/* currentTime Not a pure module */ diff --git a/tests/gentype_tests/typescript-react-example/src/nested/Types.res b/tests/gentype_tests/typescript-react-example/src/nested/NestedTypes.res similarity index 100% rename from tests/gentype_tests/typescript-react-example/src/nested/Types.res rename to tests/gentype_tests/typescript-react-example/src/nested/NestedTypes.res From e549e133ae561e7845c62b967b5e108da429aa1d Mon Sep 17 00:00:00 2001 From: nojaf Date: Tue, 22 Jul 2025 13:24:09 +0200 Subject: [PATCH 07/14] Force bsc-jsx-module flag in file --- .../tests-generic-jsx-transform/src/GenericJsxCompletion.res | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/analysis_tests/tests-generic-jsx-transform/src/GenericJsxCompletion.res b/tests/analysis_tests/tests-generic-jsx-transform/src/GenericJsxCompletion.res index babce4b57e..a57394e4f5 100644 --- a/tests/analysis_tests/tests-generic-jsx-transform/src/GenericJsxCompletion.res +++ b/tests/analysis_tests/tests-generic-jsx-transform/src/GenericJsxCompletion.res @@ -1,3 +1,7 @@ +@@config({ + flags: ["-bs-jsx", "4", "-bs-jsx-module", "GenericJsx"], +}) + //
Date: Wed, 23 Jul 2025 09:09:20 +0200 Subject: [PATCH 08/14] Don't clean rescript repo runtime --- rewatch/src/build/clean.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/rewatch/src/build/clean.rs b/rewatch/src/build/clean.rs index 10ff053e28..8d0d4a6596 100644 --- a/rewatch/src/build/clean.rs +++ b/rewatch/src/build/clean.rs @@ -375,7 +375,10 @@ pub fn clean(path: &Path, show_progress: bool, snapshot_output: bool, build_dev_ let path_str = package.get_ocaml_build_path(); let path = std::path::Path::new(&path_str); - let _ = std::fs::remove_dir_all(path); + // This is hacky check that the runtime is not cleaned for rescript repository + if package.name != "rescript" { + let _ = std::fs::remove_dir_all(path); + } }); let timing_clean_compiler_assets_elapsed = timing_clean_compiler_assets.elapsed(); From 23011dcae68212a9f2ce694394889e2287bdb1c5 Mon Sep 17 00:00:00 2001 From: nojaf Date: Wed, 23 Jul 2025 09:10:10 +0200 Subject: [PATCH 09/14] Use root bsc flags --- rescript.json | 11 ++++++++++- rewatch/src/build/compile.rs | 4 +++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/rescript.json b/rescript.json index 81a65948fd..f73c3a5059 100644 --- a/rescript.json +++ b/rescript.json @@ -1,4 +1,13 @@ { "name": "rescript", - "bs-dependencies": ["@tests/gentype-react-example"] + "bs-dependencies": [ + "@tests/gentype-react-example", + "@tests/rescript-react", + "@tests/analysis", + "@tests/generic-jsx-transform", + "@tests/reanalyze-deadcode", + "@tests/incremental-typechecking", + "@tests/reanalyze-termination" + ], + "jsx": { "version": 4 } } diff --git a/rewatch/src/build/compile.rs b/rewatch/src/build/compile.rs index e5816347c8..a9d1c1ff68 100644 --- a/rewatch/src/build/compile.rs +++ b/rewatch/src/build/compile.rs @@ -361,6 +361,7 @@ pub fn compiler_args( is_type_dev: bool, is_local_dep: bool, ) -> Vec { + let root_bsc_flags = config::flatten_flags(&root_config.compiler_flags); let bsc_flags = config::flatten_flags(&config.compiler_flags); let dependency_paths = get_dependency_paths(config, project_root, workspace_root, packages, is_type_dev); @@ -389,7 +390,7 @@ pub fn compiler_args( }; let jsx_args = root_config.get_jsx_args(); - let jsx_module_args = root_config.get_jsx_module_args(); + let jsx_module_args = config.get_jsx_module_args(); let jsx_mode_args = root_config.get_jsx_mode_args(); let jsx_preserve_args = root_config.get_jsx_preserve_args(); let gentype_arg = config.get_gentype_arg(); @@ -454,6 +455,7 @@ pub fn compiler_args( jsx_module_args, jsx_mode_args, jsx_preserve_args, + root_bsc_flags.to_owned(), bsc_flags.to_owned(), warning_args, gentype_arg, From 01d09040ffeb95c5191d1dad90a5af33e20643cb Mon Sep 17 00:00:00 2001 From: nojaf Date: Wed, 23 Jul 2025 12:13:14 +0200 Subject: [PATCH 10/14] Add missing dep --- tests/analysis_tests/tests-reanalyze/deadcode/rescript.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/analysis_tests/tests-reanalyze/deadcode/rescript.json b/tests/analysis_tests/tests-reanalyze/deadcode/rescript.json index 6b58246e82..cad68b5e8d 100644 --- a/tests/analysis_tests/tests-reanalyze/deadcode/rescript.json +++ b/tests/analysis_tests/tests-reanalyze/deadcode/rescript.json @@ -7,7 +7,7 @@ }, "name": "@tests/reanalyze-deadcode", "jsx": { "version": 4 }, - "dependencies": ["@tests/rescript-react"], + "dependencies": ["@tests/rescript-react", "@tests/gentype-react-example"], "sources": [ { "dir": "src", From a84e5006b7491785c397ce8a2b8967575be97f6d Mon Sep 17 00:00:00 2001 From: nojaf Date: Wed, 23 Jul 2025 13:14:46 +0200 Subject: [PATCH 11/14] Update ref usage --- .../data/idempotency/reason-react/src/ReactDOMRe.res | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/syntax_tests/data/idempotency/reason-react/src/ReactDOMRe.res b/tests/syntax_tests/data/idempotency/reason-react/src/ReactDOMRe.res index 49b21613c0..2c4bd1d936 100644 --- a/tests/syntax_tests/data/idempotency/reason-react/src/ReactDOMRe.res +++ b/tests/syntax_tests/data/idempotency/reason-react/src/ReactDOMRe.res @@ -81,7 +81,7 @@ type domRef module Ref = { type t = domRef - type currentDomRef = React.Ref.t> + type currentDomRef = React.ref> type callbackDomRef = Js.nullable => unit external domRef: currentDomRef => domRef = "%identity" From 6a12cc1069fcb2daf93ce012d319ba148cf526a0 Mon Sep 17 00:00:00 2001 From: nojaf Date: Wed, 23 Jul 2025 13:19:01 +0200 Subject: [PATCH 12/14] Try and fix problem where relative ast paths could be incorrect. --- rewatch/src/build/compile.rs | 35 +++++++++++++++++++++++++++++++-- rewatch/src/build/deps.rs | 38 +++++++++++++++++++++++++++++++----- rewatch/src/helpers.rs | 4 ++-- 3 files changed, 68 insertions(+), 9 deletions(-) diff --git a/rewatch/src/build/compile.rs b/rewatch/src/build/compile.rs index a9d1c1ff68..269b27675b 100644 --- a/rewatch/src/build/compile.rs +++ b/rewatch/src/build/compile.rs @@ -159,10 +159,24 @@ pub fn compile( let interface_result = match source_file.interface.to_owned() { Some(Interface { path, .. }) => { + // FIX: Use absolute paths for interface AST files (same issue as implementation files) + let ast_path = &helpers::get_compiler_asset( + package, + &packages::Namespace::NoNamespace, + &path, + "iast", + ); + + log::debug!( + "compile: interface ast_path={:?} exists={}", + ast_path, + ast_path.exists() + ); + let result = compile_file( package, root_package, - &helpers::get_ast_path(&path), + ast_path, module, true, &build_state.bsc_path, @@ -174,10 +188,27 @@ pub fn compile( } _ => None, }; + // FIX: Use absolute paths for AST files to resolve cross-package dependencies correctly + // Same issue as in deps.rs: relative paths fail in workspace builds where AST files + // are created in lib/bs/ and copied to lib/ocaml/. Using get_compiler_asset() + // ensures we get the correct absolute paths. + let impl_ast_path = &helpers::get_compiler_asset( + package, + &packages::Namespace::NoNamespace, + &source_file.implementation.path, + "ast", + ); + + log::debug!( + "compile: implementation ast_path={:?} exists={}", + impl_ast_path, + impl_ast_path.exists() + ); + let result = compile_file( package, root_package, - &helpers::get_ast_path(&source_file.implementation.path), + impl_ast_path, module, false, &build_state.bsc_path, diff --git a/rewatch/src/build/deps.rs b/rewatch/src/build/deps.rs index 8159cdc5f3..c5945aeab3 100644 --- a/rewatch/src/build/deps.rs +++ b/rewatch/src/build/deps.rs @@ -13,7 +13,16 @@ fn get_dep_modules( build_state: &BuildState, ) -> AHashSet { let mut deps = AHashSet::new(); - let ast_file = package.get_build_path().join(ast_file); + + // FIX: Handle both absolute and relative paths for AST files + // This is needed because we now pass absolute paths from get_compiler_asset() + // but the function was originally designed for relative paths + let ast_file = if std::path::Path::new(ast_file).is_absolute() { + std::path::PathBuf::from(ast_file) + } else { + package.get_build_path().join(ast_file) + }; + match helpers::read_lines(&ast_file) { Ok(lines) => { // we skip the first line with is some null characters @@ -107,7 +116,19 @@ pub fn get_deps(build_state: &mut BuildState, deleted_modules: &AHashSet let package = build_state .get_package(&module.package_name) .expect("Package not found"); - let ast_path = helpers::get_ast_path(&source_file.implementation.path); + + // FIX: Use absolute paths for AST files to resolve cross-package dependencies correctly + // The issue: get_ast_path() returns relative paths like "src/Types.ast" which work for + // single-package builds but fail in workspace builds where BSC creates AST files in + // lib/bs/ and they're later copied to lib/ocaml/. Using get_compiler_asset() ensures + // we get absolute paths to the correct lib/ocaml/ location where AST files are stored. + let ast_path = helpers::get_compiler_asset( + package, + &packages::Namespace::NoNamespace, + &source_file.implementation.path, + "ast", + ); + if module.deps_dirty || !build_state.deps_initialized { let mut deps = get_dep_modules( &ast_path.to_string_lossy(), @@ -119,16 +140,23 @@ pub fn get_deps(build_state: &mut BuildState, deleted_modules: &AHashSet ); if let Some(interface) = &source_file.interface { - let iast_path = helpers::get_ast_path(&interface.path); + // FIX: Use absolute paths for interface AST files (same issue as implementation files) + let iast_path = helpers::get_compiler_asset( + package, + &packages::Namespace::NoNamespace, + &interface.path, + "iast", + ); - deps.extend(get_dep_modules( + let interface_deps = get_dep_modules( &iast_path.to_string_lossy(), package.namespace.to_suffix(), package.modules.as_ref().unwrap(), all_mod, package, build_state, - )) + ); + deps.extend(interface_deps) } match &package.namespace { packages::Namespace::NamespaceWithEntry { namespace: _, entry } diff --git a/rewatch/src/helpers.rs b/rewatch/src/helpers.rs index 04427a8df1..01472fca3f 100644 --- a/rewatch/src/helpers.rs +++ b/rewatch/src/helpers.rs @@ -242,8 +242,8 @@ pub fn get_compiler_asset( source_file: &Path, extension: &str, ) -> PathBuf { - let namespace = match extension { - "ast" | "iast" => &packages::Namespace::NoNamespace, + let namespace = match namespace { + packages::Namespace::NoNamespace => &packages::Namespace::NoNamespace, _ => namespace, }; let basename = file_path_to_compiler_asset_basename(source_file, namespace); From cf65c961558d3b4dc75e674187fa9db82e3a22a3 Mon Sep 17 00:00:00 2001 From: nojaf Date: Wed, 23 Jul 2025 13:19:51 +0200 Subject: [PATCH 13/14] Another ref usage problem --- tests/gentype_tests/typescript-react-example/src/Hooks.res | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/gentype_tests/typescript-react-example/src/Hooks.res b/tests/gentype_tests/typescript-react-example/src/Hooks.res index 5468269e3a..a324e9d015 100644 --- a/tests/gentype_tests/typescript-react-example/src/Hooks.res +++ b/tests/gentype_tests/typescript-react-example/src/Hooks.res @@ -103,7 +103,7 @@ module ForwardRef = { @genType type testReactContext = React.Context.t -@genType type testReactRef = React.Ref.t +@genType type testReactRef = React.ref @genType type testDomRef = ReactDOM.domRef From 0cef7b4e205afa599ad684124a17cc578cd07777 Mon Sep 17 00:00:00 2001 From: nojaf Date: Wed, 23 Jul 2025 13:21:16 +0200 Subject: [PATCH 14/14] Update snapshots for now --- .../src/expected/GenericJsxCompletion.res.txt | 52 ++++++++--------- .../ConstructorCompletion__Json.res.txt | 17 ++---- .../ConstructorCompletion__Own.res.txt | 17 ++---- .../src/expected/CompletionAttributes.res.txt | 6 +- .../expected/CompletionExpressions.res.txt | 4 +- .../expected/CompletionInferValues.res.txt | 57 ++----------------- .../tests/src/expected/CompletionJsx.res.txt | 10 +--- .../src/expected/CompletionJsxProps.res.txt | 27 +-------- .../src/expected/CompletionPipeChain.res.txt | 22 +------ .../tests/src/expected/Div.res.txt | 10 +--- .../tests/src/expected/Fragment.res.txt | 4 +- .../tests/src/expected/Hover.res.txt | 2 +- .../tests/src/expected/Jsx2.res.txt | 20 +------ .../tests/src/expected/Jsx2.resi.txt | 16 +----- .../tests/src/expected/JsxV4.res.txt | 2 +- 15 files changed, 59 insertions(+), 207 deletions(-) diff --git a/tests/analysis_tests/tests-generic-jsx-transform/src/expected/GenericJsxCompletion.res.txt b/tests/analysis_tests/tests-generic-jsx-transform/src/expected/GenericJsxCompletion.res.txt index eb40ec0ba9..55237d28fb 100644 --- a/tests/analysis_tests/tests-generic-jsx-transform/src/expected/GenericJsxCompletion.res.txt +++ b/tests/analysis_tests/tests-generic-jsx-transform/src/expected/GenericJsxCompletion.res.txt @@ -1,6 +1,6 @@ -Complete src/GenericJsxCompletion.res 0:8 -posCursor:[0:8] posNoWhite:[0:6] Found expr:[0:3->0:7] -JSX 0:7] > _children:None +Complete src/GenericJsxCompletion.res 4:8 +posCursor:[4:8] posNoWhite:[4:6] Found expr:[4:3->4:7] +JSX 4:7] > _children:None Completable: Cjsx([div], "", []) Package opens Stdlib.place holder Pervasives.JsxModules.place holder Resolved opens 1 Stdlib @@ -25,9 +25,9 @@ Path GenericJsx.Elements.props "documentation": null }] -Complete src/GenericJsxCompletion.res 3:17 -posCursor:[3:17] posNoWhite:[3:16] Found expr:[3:3->3:18] -JSX 3:7] testing[3:8->3:15]=...[3:16->3:18]> _children:None +Complete src/GenericJsxCompletion.res 7:17 +posCursor:[7:17] posNoWhite:[7:16] Found expr:[7:3->7:18] +JSX 7:7] testing[7:8->7:15]=...[7:16->7:18]> _children:None Completable: Cexpression CJsxPropValue [div] testing->recordBody Package opens Stdlib.place holder Pervasives.JsxModules.place holder Resolved opens 1 Stdlib @@ -47,15 +47,15 @@ Path GenericJsx.Elements.props "documentation": null }] -Complete src/GenericJsxCompletion.res 14:21 -posCursor:[14:21] posNoWhite:[14:20] Found expr:[8:13->23:3] -posCursor:[14:21] posNoWhite:[14:20] Found expr:[9:4->22:10] -posCursor:[14:21] posNoWhite:[14:20] Found expr:[10:4->22:10] -posCursor:[14:21] posNoWhite:[14:20] Found expr:[11:4->22:10] -posCursor:[14:21] posNoWhite:[14:20] Found expr:[12:4->22:10] -posCursor:[14:21] posNoWhite:[14:20] Found expr:[13:4->22:10] -posCursor:[14:21] posNoWhite:[14:20] Found expr:[14:7->22:10] -posCursor:[14:21] posNoWhite:[14:20] Found expr:[14:7->14:21] +Complete src/GenericJsxCompletion.res 18:21 +posCursor:[18:21] posNoWhite:[18:20] Found expr:[12:13->27:3] +posCursor:[18:21] posNoWhite:[18:20] Found expr:[13:4->26:10] +posCursor:[18:21] posNoWhite:[18:20] Found expr:[14:4->26:10] +posCursor:[18:21] posNoWhite:[18:20] Found expr:[15:4->26:10] +posCursor:[18:21] posNoWhite:[18:20] Found expr:[16:4->26:10] +posCursor:[18:21] posNoWhite:[18:20] Found expr:[17:4->26:10] +posCursor:[18:21] posNoWhite:[18:20] Found expr:[18:7->26:10] +posCursor:[18:21] posNoWhite:[18:20] Found expr:[18:7->18:21] Completable: Cpath Value[someString]->st <> Package opens Stdlib.place holder Pervasives.JsxModules.place holder Resolved opens 1 Stdlib @@ -86,17 +86,17 @@ Path st "documentation": {"kind": "markdown", "value": "\n`startsWithFrom(str, substr, n)` returns `true` if the `str` starts\nwith `substr` starting at position `n`, `false` otherwise. If `n` is negative,\nthe search starts at the beginning of `str`.\nSee [`String.startsWith`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/startsWith) on MDN.\n\n## Examples\n\n```rescript\nString.startsWithFrom(\"BuckleScript\", \"kle\", 3) == true\nString.startsWithFrom(\"BuckleScript\", \"\", 3) == true\nString.startsWithFrom(\"JavaScript\", \"Buckle\", 2) == false\n```\n"} }] -Complete src/GenericJsxCompletion.res 20:24 -posCursor:[20:24] posNoWhite:[20:23] Found expr:[8:13->23:3] -posCursor:[20:24] posNoWhite:[20:23] Found expr:[9:4->22:10] -posCursor:[20:24] posNoWhite:[20:23] Found expr:[10:4->22:10] -posCursor:[20:24] posNoWhite:[20:23] Found expr:[11:4->22:10] -posCursor:[20:24] posNoWhite:[20:23] Found expr:[12:4->22:10] -posCursor:[20:24] posNoWhite:[20:23] Found expr:[13:4->22:10] -posCursor:[20:24] posNoWhite:[20:23] Found expr:[16:4->22:10] -posCursor:[20:24] posNoWhite:[20:23] Found expr:[17:4->22:10] -JSX 17:8] > _children:18:7 -posCursor:[20:24] posNoWhite:[20:23] Found expr:[20:10->20:24] +Complete src/GenericJsxCompletion.res 24:24 +posCursor:[24:24] posNoWhite:[24:23] Found expr:[12:13->27:3] +posCursor:[24:24] posNoWhite:[24:23] Found expr:[13:4->26:10] +posCursor:[24:24] posNoWhite:[24:23] Found expr:[14:4->26:10] +posCursor:[24:24] posNoWhite:[24:23] Found expr:[15:4->26:10] +posCursor:[24:24] posNoWhite:[24:23] Found expr:[16:4->26:10] +posCursor:[24:24] posNoWhite:[24:23] Found expr:[17:4->26:10] +posCursor:[24:24] posNoWhite:[24:23] Found expr:[20:4->26:10] +posCursor:[24:24] posNoWhite:[24:23] Found expr:[21:4->26:10] +JSX 21:8] > _children:22:7 +posCursor:[24:24] posNoWhite:[24:23] Found expr:[24:10->24:24] Completable: Cpath Value[someString]->st <> Raw opens: 1 GenericJsx.place holder Package opens Stdlib.place holder Pervasives.JsxModules.place holder diff --git a/tests/analysis_tests/tests-incremental-typechecking/src/expected/ConstructorCompletion__Json.res.txt b/tests/analysis_tests/tests-incremental-typechecking/src/expected/ConstructorCompletion__Json.res.txt index bab658f9b9..d123400e72 100644 --- a/tests/analysis_tests/tests-incremental-typechecking/src/expected/ConstructorCompletion__Json.res.txt +++ b/tests/analysis_tests/tests-incremental-typechecking/src/expected/ConstructorCompletion__Json.res.txt @@ -1,20 +1,11 @@ -Complete src/ConstructorCompletion__Json.res 0:22 -posCursor:[0:22] posNoWhite:[0:21] Found expr:[0:8->0:23] +Complete src/ConstructorCompletion__Json.res 0:25 +posCursor:[0:25] posNoWhite:[0:24] Found expr:[0:11->0:26] Pexp_construct Js Json -Array:[0:8->0:21] [0:21->0:23] +Array:[0:11->0:24] [0:24->0:26] Completable: Cexpression CTypeAtPos()->variantPayload::Array($0) Package opens Stdlib.place holder Pervasives.JsxModules.place holder Resolved opens 1 Stdlib ContextPath CTypeAtPos() -[{ - "label": "[]", - "kind": 12, - "tags": [], - "detail": "t", - "documentation": {"kind": "markdown", "value": " \nA type representing a JSON object.\n\n\n```rescript\n@unboxed\ntype t =\n | Boolean(bool)\n | @as(null) Null\n | String(string)\n | Number(float)\n | Object(dict)\n | Array(array)\n```"}, - "sortText": "A", - "insertText": "[$0]", - "insertTextFormat": 2 - }] +[] diff --git a/tests/analysis_tests/tests-incremental-typechecking/src/expected/ConstructorCompletion__Own.res.txt b/tests/analysis_tests/tests-incremental-typechecking/src/expected/ConstructorCompletion__Own.res.txt index 6ea8bab362..45b850d349 100644 --- a/tests/analysis_tests/tests-incremental-typechecking/src/expected/ConstructorCompletion__Own.res.txt +++ b/tests/analysis_tests/tests-incremental-typechecking/src/expected/ConstructorCompletion__Own.res.txt @@ -1,19 +1,10 @@ -Complete src/ConstructorCompletion__Own.res 4:24 -posCursor:[4:24] posNoWhite:[4:23] Found expr:[4:8->4:25] +Complete src/ConstructorCompletion__Own.res 4:27 +posCursor:[4:27] posNoWhite:[4:26] Found expr:[4:11->4:28] Pexp_construct WithVariant -One:[4:8->4:23] [4:23->4:25] +One:[4:11->4:26] [4:26->4:28] Completable: Cexpression CTypeAtPos()->variantPayload::One($0) Package opens Stdlib.place holder Pervasives.JsxModules.place holder Resolved opens 1 Stdlib ContextPath CTypeAtPos() -[{ - "label": "{}", - "kind": 12, - "tags": [], - "detail": "{miss: bool}", - "documentation": {"kind": "markdown", "value": "```rescript\n{miss: bool}\n```"}, - "sortText": "A", - "insertText": "{$0}", - "insertTextFormat": 2 - }] +[] diff --git a/tests/analysis_tests/tests/src/expected/CompletionAttributes.res.txt b/tests/analysis_tests/tests/src/expected/CompletionAttributes.res.txt index 1c7c3fb9df..7fd7dce602 100644 --- a/tests/analysis_tests/tests/src/expected/CompletionAttributes.res.txt +++ b/tests/analysis_tests/tests/src/expected/CompletionAttributes.res.txt @@ -19,7 +19,7 @@ Completable: CdecoratorPayload(module=) Package opens Stdlib.place holder Pervasives.JsxModules.place holder Resolved opens 1 Stdlib [{ - "label": "@rescript/react", + "label": "@tests/rescript-react", "kind": 4, "tags": [], "detail": "Package", @@ -186,7 +186,7 @@ Completable: CdecoratorPayload(module=) Package opens Stdlib.place holder Pervasives.JsxModules.place holder Resolved opens 1 Stdlib [{ - "label": "@rescript/react", + "label": "@tests/rescript-react", "kind": 4, "tags": [], "detail": "Package", @@ -211,7 +211,7 @@ Completable: CdecoratorPayload(module=) Package opens Stdlib.place holder Pervasives.JsxModules.place holder Resolved opens 1 Stdlib [{ - "label": "@rescript/react", + "label": "@tests/rescript-react", "kind": 4, "tags": [], "detail": "Package", diff --git a/tests/analysis_tests/tests/src/expected/CompletionExpressions.res.txt b/tests/analysis_tests/tests/src/expected/CompletionExpressions.res.txt index ddd83b7e52..271a46efec 100644 --- a/tests/analysis_tests/tests/src/expected/CompletionExpressions.res.txt +++ b/tests/analysis_tests/tests/src/expected/CompletionExpressions.res.txt @@ -865,13 +865,13 @@ ContextPath CArgument Value[fnTakingCallback]($2) ContextPath Value[fnTakingCallback] Path fnTakingCallback [{ - "label": "event => event", + "label": "mouse => mouse", "kind": 12, "tags": [], "detail": "ReactEvent.Mouse.t => unit", "documentation": null, "sortText": "A", - "insertText": "${1:event} => ${0:event}", + "insertText": "${1:mouse} => ${0:mouse}", "insertTextFormat": 2 }] diff --git a/tests/analysis_tests/tests/src/expected/CompletionInferValues.res.txt b/tests/analysis_tests/tests/src/expected/CompletionInferValues.res.txt index dc885d8485..81a3f89f3d 100644 --- a/tests/analysis_tests/tests/src/expected/CompletionInferValues.res.txt +++ b/tests/analysis_tests/tests/src/expected/CompletionInferValues.res.txt @@ -250,16 +250,7 @@ ContextPath CArgument CArgument Value[reactEventFn]($0)($0) ContextPath CArgument Value[reactEventFn]($0) ContextPath Value[reactEventFn] Path reactEventFn -CPPipe pathFromEnv:ReactEvent.Mouse found:false -Path ReactEvent.Mouse.pr -Path pr -[{ - "label": "ReactEvent.Mouse.preventDefault", - "kind": 12, - "tags": [], - "detail": "t => unit", - "documentation": null - }] +[] Complete src/CompletionInferValues.res 41:50 posCursor:[41:50] posNoWhite:[41:49] Found expr:[41:11->41:56] @@ -275,17 +266,7 @@ Path event ContextPath CArgument CJsxPropValue [div] onMouseEnter($0) ContextPath CJsxPropValue [div] onMouseEnter Path ReactDOM.domProps -Path JsxDOM.domProps -CPPipe pathFromEnv:JsxEvent.Mouse found:false -Path JsxEvent.Mouse.pr -Path pr -[{ - "label": "JsxEvent.Mouse.preventDefault", - "kind": 12, - "tags": [], - "detail": "t => unit", - "documentation": null - }] +[] Complete src/CompletionInferValues.res 44:50 posCursor:[44:50] posNoWhite:[44:49] Found expr:[44:11->44:56] @@ -832,22 +813,7 @@ ContextPath CArgument CArgument Value[fn2](~cb)($0) ContextPath CArgument Value[fn2](~cb) ContextPath Value[fn2] Path fn2 -CPPipe pathFromEnv:ReactDOM.Client.Root found:false -Path ReactDOM.Client.Root. -Path -[{ - "label": "ReactDOM.Client.Root.unmount", - "kind": 12, - "tags": [], - "detail": "(t, unit) => unit", - "documentation": null - }, { - "label": "ReactDOM.Client.Root.render", - "kind": 12, - "tags": [], - "detail": "(t, React.element) => unit", - "documentation": null - }] +[] Complete src/CompletionInferValues.res 139:30 posCursor:[139:30] posNoWhite:[139:29] Found expr:[139:3->139:33] @@ -974,22 +940,7 @@ ContextPath CArgument CArgument Value[CompletionSupport2, makeRenderer](~render) ContextPath CArgument Value[CompletionSupport2, makeRenderer](~render) ContextPath Value[CompletionSupport2, makeRenderer] Path CompletionSupport2.makeRenderer -CPPipe pathFromEnv:ReactDOM.Client.Root found:false -Path ReactDOM.Client.Root. -Path -[{ - "label": "ReactDOM.Client.Root.unmount", - "kind": 12, - "tags": [], - "detail": "(t, unit) => unit", - "documentation": null - }, { - "label": "ReactDOM.Client.Root.render", - "kind": 12, - "tags": [], - "detail": "(t, React.element) => unit", - "documentation": null - }] +[] Hover src/CompletionInferValues.res 160:27 Nothing at that position. Now trying to use completion. diff --git a/tests/analysis_tests/tests/src/expected/CompletionJsx.res.txt b/tests/analysis_tests/tests/src/expected/CompletionJsx.res.txt index e9907b0a2b..d0f15fb426 100644 --- a/tests/analysis_tests/tests/src/expected/CompletionJsx.res.txt +++ b/tests/analysis_tests/tests/src/expected/CompletionJsx.res.txt @@ -629,14 +629,8 @@ Completable: Cjsx([h1], hidd, [hidd]) Package opens Stdlib.place holder Pervasives.JsxModules.place holder Resolved opens 1 Stdlib Path ReactDOM.domProps -Path JsxDOM.domProps -[{ - "label": "hidden", - "kind": 4, - "tags": [], - "detail": "bool", - "documentation": null - }] +[completing-lowercase-jsx] could not find element props to complete from. +[] Complete src/CompletionJsx.res 61:30 posCursor:[61:30] posNoWhite:[61:28] Found expr:[61:3->61:29] diff --git a/tests/analysis_tests/tests/src/expected/CompletionJsxProps.res.txt b/tests/analysis_tests/tests/src/expected/CompletionJsxProps.res.txt index 686f4f5ec9..8d83639661 100644 --- a/tests/analysis_tests/tests/src/expected/CompletionJsxProps.res.txt +++ b/tests/analysis_tests/tests/src/expected/CompletionJsxProps.res.txt @@ -223,20 +223,7 @@ Package opens Stdlib.place holder Pervasives.JsxModules.place holder Resolved opens 1 Stdlib ContextPath CJsxPropValue [div] muted Path ReactDOM.domProps -Path JsxDOM.domProps -[{ - "label": "true", - "kind": 4, - "tags": [], - "detail": "bool", - "documentation": null - }, { - "label": "false", - "kind": 4, - "tags": [], - "detail": "bool", - "documentation": null - }] +[] Complete src/CompletionJsxProps.res 18:29 posCursor:[18:29] posNoWhite:[18:28] Found expr:[18:11->18:32] @@ -246,17 +233,7 @@ Package opens Stdlib.place holder Pervasives.JsxModules.place holder Resolved opens 1 Stdlib ContextPath CJsxPropValue [div] onMouseEnter Path ReactDOM.domProps -Path JsxDOM.domProps -[{ - "label": "event => event", - "kind": 12, - "tags": [], - "detail": "JsxEvent.Mouse.t => unit", - "documentation": null, - "sortText": "A", - "insertText": "{${1:event} => ${0:event}}", - "insertTextFormat": 2 - }] +[] Complete src/CompletionJsxProps.res 22:52 posCursor:[22:52] posNoWhite:[22:51] Found expr:[22:11->22:52] diff --git a/tests/analysis_tests/tests/src/expected/CompletionPipeChain.res.txt b/tests/analysis_tests/tests/src/expected/CompletionPipeChain.res.txt index 4fb8e0849f..ca7001b897 100644 --- a/tests/analysis_tests/tests/src/expected/CompletionPipeChain.res.txt +++ b/tests/analysis_tests/tests/src/expected/CompletionPipeChain.res.txt @@ -470,16 +470,7 @@ Path support CPPipe pathFromEnv:CompletionSupport.Nested found:false Path CompletionSupport.Nested.root Path root -CPPipe pathFromEnv:ReactDOM.Client.Root found:false -Path ReactDOM.Client.Root.ren -Path ren -[{ - "label": "ReactDOM.Client.Root.render", - "kind": 12, - "tags": [], - "detail": "(t, React.element) => unit", - "documentation": null - }] +[] Complete src/CompletionPipeChain.res 88:16 posCursor:[88:16] posNoWhite:[88:15] Found expr:[76:15->93:1] @@ -496,16 +487,7 @@ Resolved opens 1 Stdlib ContextPath Value[root]->ren ContextPath Value[root] Path root -CPPipe pathFromEnv:ReactDOM.Client.Root found:false -Path ReactDOM.Client.Root.ren -Path ren -[{ - "label": "ReactDOM.Client.Root.render", - "kind": 12, - "tags": [], - "detail": "(t, React.element) => unit", - "documentation": null - }] +[] Complete src/CompletionPipeChain.res 95:20 posCursor:[95:20] posNoWhite:[95:19] Found expr:[95:3->95:21] diff --git a/tests/analysis_tests/tests/src/expected/Div.res.txt b/tests/analysis_tests/tests/src/expected/Div.res.txt index deb951ada8..966984d6bc 100644 --- a/tests/analysis_tests/tests/src/expected/Div.res.txt +++ b/tests/analysis_tests/tests/src/expected/Div.res.txt @@ -8,12 +8,6 @@ Completable: Cjsx([div], dangerous, [dangerous]) Package opens Stdlib.place holder Pervasives.JsxModules.place holder Resolved opens 1 Stdlib Path ReactDOM.domProps -Path JsxDOM.domProps -[{ - "label": "dangerouslySetInnerHTML", - "kind": 4, - "tags": [], - "detail": "{\"__html\": string}", - "documentation": null - }] +[completing-lowercase-jsx] could not find element props to complete from. +[] diff --git a/tests/analysis_tests/tests/src/expected/Fragment.res.txt b/tests/analysis_tests/tests/src/expected/Fragment.res.txt index 689d63155e..f23606a816 100644 --- a/tests/analysis_tests/tests/src/expected/Fragment.res.txt +++ b/tests/analysis_tests/tests/src/expected/Fragment.res.txt @@ -1,6 +1,6 @@ Hover src/Fragment.res 6:19 -{"contents": {"kind": "markdown", "value": "```rescript\nReact.component>\n```\n\n---\n\n```\n \n```\n```rescript\ntype React.component<'props> = Jsx.component<'props>\n```\nGo to: [Type definition](command:rescript-vscode.go_to_location?%5B%22React.res%22%2C12%2C0%5D)\n\n\n---\n\n```\n \n```\n```rescript\ntype SectionHeader.props<'children> = {children: 'children}\n```\nGo to: [Type definition](command:rescript-vscode.go_to_location?%5B%22Fragment.res%22%2C1%2C2%5D)\n\n\n---\n\n```\n \n```\n```rescript\ntype React.element = Jsx.element\n```\nGo to: [Type definition](command:rescript-vscode.go_to_location?%5B%22React.res%22%2C0%2C0%5D)\n"}} +{"contents": {"kind": "markdown", "value": "```rescript\nReact.component>\n```\n\n---\n\n```\n \n```\n```rescript\ntype SectionHeader.props<'children> = {children: 'children}\n```\nGo to: [Type definition](command:rescript-vscode.go_to_location?%5B%22Fragment.res%22%2C1%2C2%5D)\n"}} Hover src/Fragment.res 9:56 -{"contents": {"kind": "markdown", "value": "```rescript\nReact.component\n```\n\n---\n\n```\n \n```\n```rescript\ntype React.component<'props> = Jsx.component<'props>\n```\nGo to: [Type definition](command:rescript-vscode.go_to_location?%5B%22React.res%22%2C12%2C0%5D)\n\n\n---\n\n```\n \n```\n```rescript\ntype React.fragmentProps = {children?: element}\n```\nGo to: [Type definition](command:rescript-vscode.go_to_location?%5B%22React.res%22%2C41%2C0%5D)\n"}} +{"contents": {"kind": "markdown", "value": "```rescript\nReact.component\n```"}} diff --git a/tests/analysis_tests/tests/src/expected/Hover.res.txt b/tests/analysis_tests/tests/src/expected/Hover.res.txt index a68c232167..78f9ffbe91 100644 --- a/tests/analysis_tests/tests/src/expected/Hover.res.txt +++ b/tests/analysis_tests/tests/src/expected/Hover.res.txt @@ -253,7 +253,7 @@ Path }] Hover src/Hover.res 197:4 -{"contents": {"kind": "markdown", "value": "```rescript\nCompV4.props => React.element\n```\n\n---\n\n```\n \n```\n```rescript\ntype CompV4.props<'n, 's> = {n?: 'n, s: 's}\n```\nGo to: [Type definition](command:rescript-vscode.go_to_location?%5B%22Hover.res%22%2C190%2C2%5D)\n\n\n---\n\n```\n \n```\n```rescript\ntype React.element = Jsx.element\n```\nGo to: [Type definition](command:rescript-vscode.go_to_location?%5B%22React.res%22%2C0%2C0%5D)\n"}} +{"contents": {"kind": "markdown", "value": "```rescript\nCompV4.props => React.element\n```\n\n---\n\n```\n \n```\n```rescript\ntype CompV4.props<'n, 's> = {n?: 'n, s: 's}\n```\nGo to: [Type definition](command:rescript-vscode.go_to_location?%5B%22Hover.res%22%2C190%2C2%5D)\n"}} Hover src/Hover.res 202:16 {"contents": {"kind": "markdown", "value": "```rescript\nuseR\n```\n\n---\n\n```\n \n```\n```rescript\ntype useR = {x: int, y: list>>}\n```\nGo to: [Type definition](command:rescript-vscode.go_to_location?%5B%22Hover.res%22%2C200%2C0%5D)\n\n\n---\n\n```\n \n```\n```rescript\ntype r<'a> = {i: 'a, f: float}\n```\nGo to: [Type definition](command:rescript-vscode.go_to_location?%5B%22Hover.res%22%2C101%2C0%5D)\n"}} diff --git a/tests/analysis_tests/tests/src/expected/Jsx2.res.txt b/tests/analysis_tests/tests/src/expected/Jsx2.res.txt index 66920cb633..5f60fdf6ea 100644 --- a/tests/analysis_tests/tests/src/expected/Jsx2.res.txt +++ b/tests/analysis_tests/tests/src/expected/Jsx2.res.txt @@ -356,13 +356,7 @@ Package opens Stdlib.place holder Pervasives.JsxModules.place holder Resolved opens 1 Stdlib ContextPath Type[React, e] Path React.e -[{ - "label": "element", - "kind": 22, - "tags": [], - "detail": "type element", - "documentation": {"kind": "markdown", "value": "```rescript\ntype element = Jsx.element\n```"} - }] +[] Complete src/Jsx2.res 96:20 posCursor:[96:20] posNoWhite:[96:19] Found pattern:[96:7->99:6] @@ -472,17 +466,7 @@ Package opens Stdlib.place holder Pervasives.JsxModules.place holder Resolved opens 1 Stdlib ContextPath CJsxPropValue [div] x Path ReactDOM.domProps -Path JsxDOM.domProps -[{ - "label": "\"\"", - "kind": 12, - "tags": [], - "detail": "string", - "documentation": null, - "sortText": "A", - "insertText": "{\"$0\"}", - "insertTextFormat": 2 - }] +[] Complete src/Jsx2.res 150:21 posCursor:[150:21] posNoWhite:[150:20] Found expr:[150:11->150:32] diff --git a/tests/analysis_tests/tests/src/expected/Jsx2.resi.txt b/tests/analysis_tests/tests/src/expected/Jsx2.resi.txt index c34ab6fca5..c70c9688c4 100644 --- a/tests/analysis_tests/tests/src/expected/Jsx2.resi.txt +++ b/tests/analysis_tests/tests/src/expected/Jsx2.resi.txt @@ -12,13 +12,7 @@ Package opens Stdlib.place holder Pervasives.JsxModules.place holder Resolved opens 1 Stdlib ContextPath Type[React, e] Path React.e -[{ - "label": "element", - "kind": 22, - "tags": [], - "detail": "type element", - "documentation": {"kind": "markdown", "value": "```rescript\ntype element = Jsx.element\n```"} - }] +[] Complete src/Jsx2.resi 10:18 posCursor:[10:18] posNoWhite:[10:17] Found type:[10:11->10:18] @@ -28,11 +22,5 @@ Package opens Stdlib.place holder Pervasives.JsxModules.place holder Resolved opens 1 Stdlib ContextPath Type[React, e] Path React.e -[{ - "label": "element", - "kind": 22, - "tags": [], - "detail": "type element", - "documentation": {"kind": "markdown", "value": "```rescript\ntype element = Jsx.element\n```"} - }] +[] diff --git a/tests/analysis_tests/tests/src/expected/JsxV4.res.txt b/tests/analysis_tests/tests/src/expected/JsxV4.res.txt index ba54c5d047..0319c267b3 100644 --- a/tests/analysis_tests/tests/src/expected/JsxV4.res.txt +++ b/tests/analysis_tests/tests/src/expected/JsxV4.res.txt @@ -17,7 +17,7 @@ Path M4.make }] Hover src/JsxV4.res 14:9 -{"contents": {"kind": "markdown", "value": "```rescript\nReact.component>\n```\n\n---\n\n```\n \n```\n```rescript\ntype React.component<'props> = Jsx.component<'props>\n```\nGo to: [Type definition](command:rescript-vscode.go_to_location?%5B%22React.res%22%2C12%2C0%5D)\n\n\n---\n\n```\n \n```\n```rescript\ntype M4.props<'first, 'fun, 'second> = {\n first: 'first,\n fun?: 'fun,\n second?: 'second,\n}\n```\nGo to: [Type definition](command:rescript-vscode.go_to_location?%5B%22JsxV4.res%22%2C3%2C2%5D)\n\n---\n Doc Comment For M4 "}} +{"contents": {"kind": "markdown", "value": "```rescript\nReact.component>\n```\n\n---\n\n```\n \n```\n```rescript\ntype M4.props<'first, 'fun, 'second> = {\n first: 'first,\n fun?: 'fun,\n second?: 'second,\n}\n```\nGo to: [Type definition](command:rescript-vscode.go_to_location?%5B%22JsxV4.res%22%2C3%2C2%5D)\n\n---\n Doc Comment For M4 "}} Create Interface src/JsxV4.res module M4: {