Skip to content

Commit

Permalink
fix: manually add typings for generator classes (#7824)
Browse files Browse the repository at this point in the history
* fix: manually add typings for generator classes

* fix: use real generated type for class
  • Loading branch information
maribethb committed Feb 2, 2024
1 parent 0b25a8a commit d1cca3c
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 1 deletion.
1 change: 0 additions & 1 deletion scripts/gulpfiles/package_tasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,6 @@ function packageDTS() {
return gulp.src(handwrittenSrcs, {base: 'typings'})
.pipe(gulp.src(`${TYPINGS_BUILD_DIR}/**/*.d.ts`, {ignore: [
`${TYPINGS_BUILD_DIR}/blocks/**/*`,
`${TYPINGS_BUILD_DIR}/generators/**/*`,
]}))
.pipe(gulp.replace('AnyDuringMigration', 'any'))
.pipe(gulp.dest(RELEASE_DIR));
Expand Down
31 changes: 31 additions & 0 deletions tests/typescript/src/generators.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/**
* @license
* Copyright 2024 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/

import * as Blockly from 'blockly-test/core';
import {JavascriptGenerator} from 'blockly-test/javascript';
import {PhpGenerator, phpGenerator, Order} from 'blockly-test/php';
import {LuaGenerator} from 'blockly-test/lua';
import {PythonGenerator} from 'blockly-test/python';
import {DartGenerator} from 'blockly-test/dart';

JavascriptGenerator;
PhpGenerator;
LuaGenerator;
PythonGenerator;
DartGenerator;

class TestGenerator extends PhpGenerator {}

const testGenerator = new TestGenerator();

testGenerator.forBlock['test_block'] = function (
_block: Blockly.Block,
_generator: TestGenerator,
) {
return ['a fake code string', Order.ADDITION];
};

phpGenerator.quote_();
2 changes: 2 additions & 0 deletions typings/dart.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,5 @@ export enum Order {
}

export declare const dartGenerator: any;

export {DartGenerator} from './generators/dart';
2 changes: 2 additions & 0 deletions typings/javascript.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,5 @@ export enum Order {
}

export declare const javascriptGenerator: any;

export {JavascriptGenerator} from './generators/javascript';
2 changes: 2 additions & 0 deletions typings/lua.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,5 @@ export enum Order {
}

export declare const luaGenerator: any;

export {LuaGenerator} from './generators/lua';
2 changes: 2 additions & 0 deletions typings/php.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,5 @@ export enum Order {
}

export declare const phpGenerator: any;

export {PhpGenerator} from './generators/php';
2 changes: 2 additions & 0 deletions typings/python.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,5 @@ export enum Order {
}

export declare const pythonGenerator: any;

export {PythonGenerator} from './generators/python';

0 comments on commit d1cca3c

Please sign in to comment.