mirror of
				https://github.com/slint-ui/slint.git
				synced 2025-11-03 21:24:17 +00:00 
			
		
		
		
	Fix Node.js docs missing Diagnostic, DiagnosticLevel, RgbaColor, and Brush
typedoc uses typescript under the hood. An import from "rust-module.cjs" won't look for .d.ts but .d.cts as per https://www.typescriptlang.org/docs/handbook/modules/reference.html#file-extension-substitution . This way the existing warning from the TS compiler that rust-module.cjs was imported as any goes away and actual type checking is being done. The rest of this commit fixes those type errors, including missing type casts to make ts-node's transpiler not thrown an exception.
This commit is contained in:
		
							parent
							
								
									4aa81b671a
								
							
						
					
					
						commit
						22e7c4d4a6
					
				
					 6 changed files with 15 additions and 10 deletions
				
			
		
							
								
								
									
										2
									
								
								api/node/.gitignore
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								api/node/.gitignore
									
										
									
									
										vendored
									
									
								
							| 
						 | 
					@ -1,5 +1,5 @@
 | 
				
			||||||
rust-module.cjs
 | 
					rust-module.cjs
 | 
				
			||||||
rust-module.d.ts
 | 
					rust-module.d.cts
 | 
				
			||||||
index.js
 | 
					index.js
 | 
				
			||||||
docs/
 | 
					docs/
 | 
				
			||||||
npm/
 | 
					npm/
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -790,7 +790,9 @@ test("model from array", (t) => {
 | 
				
			||||||
    t.not(instance, null);
 | 
					    t.not(instance, null);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    instance!.setProperty("int-array", [10, 9, 8]);
 | 
					    instance!.setProperty("int-array", [10, 9, 8]);
 | 
				
			||||||
    const wrapped_int_model = instance!.getProperty("int-array");
 | 
					    const wrapped_int_model = instance!.getProperty(
 | 
				
			||||||
 | 
					        "int-array",
 | 
				
			||||||
 | 
					    ) as Model<number>;
 | 
				
			||||||
    t.deepEqual(Array.from(wrapped_int_model), [10, 9, 8]);
 | 
					    t.deepEqual(Array.from(wrapped_int_model), [10, 9, 8]);
 | 
				
			||||||
    t.deepEqual(wrapped_int_model.rowCount(), 3);
 | 
					    t.deepEqual(wrapped_int_model.rowCount(), 3);
 | 
				
			||||||
    t.deepEqual(wrapped_int_model.rowData(0), 10);
 | 
					    t.deepEqual(wrapped_int_model.rowData(0), 10);
 | 
				
			||||||
| 
						 | 
					@ -805,7 +807,9 @@ test("model from array", (t) => {
 | 
				
			||||||
        "Tobias",
 | 
					        "Tobias",
 | 
				
			||||||
        "Florian",
 | 
					        "Florian",
 | 
				
			||||||
    ]);
 | 
					    ]);
 | 
				
			||||||
    const wrapped_string_model = instance!.getProperty("string-array");
 | 
					    const wrapped_string_model = instance!.getProperty(
 | 
				
			||||||
 | 
					        "string-array",
 | 
				
			||||||
 | 
					    ) as Model<string>;
 | 
				
			||||||
    t.deepEqual(wrapped_string_model.rowCount(), 5);
 | 
					    t.deepEqual(wrapped_string_model.rowCount(), 5);
 | 
				
			||||||
    t.deepEqual(wrapped_string_model.rowData(0), "Simon");
 | 
					    t.deepEqual(wrapped_string_model.rowData(0), "Simon");
 | 
				
			||||||
    t.deepEqual(wrapped_string_model.rowData(1), "Olivier");
 | 
					    t.deepEqual(wrapped_string_model.rowData(1), "Olivier");
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,10 +1,10 @@
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    "extends": ["../../biome.json"],
 | 
					    "extends": ["../../biome.json"],
 | 
				
			||||||
    "formatter": {
 | 
					    "formatter": {
 | 
				
			||||||
        "ignore": ["rust-module.d.ts", "rust-module.cjs", "dist/", "docs/"]
 | 
					        "ignore": ["rust-module.d.cts", "rust-module.cjs", "dist/", "docs/"]
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    "linter": {
 | 
					    "linter": {
 | 
				
			||||||
        "ignore": ["rust-module.d.ts", "rust-module.cjs", "dist/", "docs/"],
 | 
					        "ignore": ["rust-module.d.cts", "rust-module.cjs", "dist/", "docs/"],
 | 
				
			||||||
        "rules": {
 | 
					        "rules": {
 | 
				
			||||||
            "complexity": {
 | 
					            "complexity": {
 | 
				
			||||||
                "useArrowFunction": "off",
 | 
					                "useArrowFunction": "off",
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -37,11 +37,12 @@
 | 
				
			||||||
  "scripts": {
 | 
					  "scripts": {
 | 
				
			||||||
    "artifacts": "napi artifacts",
 | 
					    "artifacts": "napi artifacts",
 | 
				
			||||||
    "compile": "tsc --build",
 | 
					    "compile": "tsc --build",
 | 
				
			||||||
    "build": "napi build --platform --release --js rust-module.cjs --dts rust-module.d.ts -c binaries.json",
 | 
					    "build": "napi build --platform --release --js rust-module.cjs --dts rust-module.d.cts -c binaries.json",
 | 
				
			||||||
    "build:debug": "napi build --platform --js rust-module.cjs --dts rust-module.d.ts -c binaries.json && pnpm compile",
 | 
					    "build:debug": "napi build --platform --js rust-module.cjs --dts rust-module.d.cts -c binaries.json && pnpm compile",
 | 
				
			||||||
    "build:testing": "napi build --platform --js rust-module.cjs --dts rust-module.d.ts -c binaries.json --features testing && pnpm compile",
 | 
					    "build:testing": "napi build --platform --js rust-module.cjs --dts rust-module.d.cts -c binaries.json --features testing && pnpm compile",
 | 
				
			||||||
    "install": "node build-on-demand.mjs",
 | 
					    "install": "node build-on-demand.mjs",
 | 
				
			||||||
    "docs": "pnpm build && typedoc --hideGenerator --readme cover.md typescript/index.ts && cargo about generate thirdparty.hbs -o docs/thirdparty.html",
 | 
					    "docs": "pnpm build && typedoc --hideGenerator --readme cover.md typescript/index.ts && cargo about generate thirdparty.hbs -o docs/thirdparty.html",
 | 
				
			||||||
 | 
					    "docs:debug": "pnpm build:debug && typedoc --hideGenerator --readme cover.md typescript/index.ts",
 | 
				
			||||||
    "check": "biome check",
 | 
					    "check": "biome check",
 | 
				
			||||||
    "format": "biome format",
 | 
					    "format": "biome format",
 | 
				
			||||||
    "format:fix": "biome format --write",
 | 
					    "format:fix": "biome format --write",
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -327,7 +327,7 @@ function loadSlint(loadData: LoadData): Object {
 | 
				
			||||||
    for (const key in compiler.structs) {
 | 
					    for (const key in compiler.structs) {
 | 
				
			||||||
        Object.defineProperty(slint_module, translateName(key), {
 | 
					        Object.defineProperty(slint_module, translateName(key), {
 | 
				
			||||||
            value: function (properties: any) {
 | 
					            value: function (properties: any) {
 | 
				
			||||||
                const defaultObject = structs[key];
 | 
					                const defaultObject = structs[key] as any;
 | 
				
			||||||
                const newObject = Object.create({});
 | 
					                const newObject = Object.create({});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                for (const propertyKey in defaultObject) {
 | 
					                for (const propertyKey in defaultObject) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -97,7 +97,7 @@ export abstract class Model<T> implements Iterable<T> {
 | 
				
			||||||
     * @hidden
 | 
					     * @hidden
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    constructor(modelNotify?: napi.ExternalObject<napi.SharedModelNotify>) {
 | 
					    constructor(modelNotify?: napi.ExternalObject<napi.SharedModelNotify>) {
 | 
				
			||||||
        this.modelNotify = modelNotify ?? napi.jsModelNotifyNew(this);
 | 
					        this.modelNotify = modelNotify ?? napi.jsModelNotifyNew();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // /**
 | 
					    // /**
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue