fix(generators): Fix generator type declarations (#7750)

* test(generators): Add generator TS import/use tests

* fix(generators): Fix generator type declarations

  Add a missing ./ prefix to the imports in the generator wrapper
  .d.ts files.

  Fixes: #7741
This commit is contained in:
Christopher Allen
2024-01-08 17:10:47 +00:00
committed by GitHub
parent 2a20a3a303
commit 4cc4bd573c
10 changed files with 129 additions and 5 deletions

View File

@@ -0,0 +1,24 @@
/**
* @license
* Copyright 2024 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
import * as Blockly from 'blockly-test/core';
/**
* Test: should be able to import a generator instance, class, and
* Order enum.
*/
import {dartGenerator, DartGenerator, Order} from 'blockly-test/dart';
/**
* Test: should be able to create a simple block generator function,
* correctly typed, and insert it into the .forBlock dictionary.
*/
dartGenerator.forBlock['the_answer'] = function (
_block: Blockly.Block,
_generator: DartGenerator,
): [string, Order] {
return ['42', Order.ATOMIC];
};

View File

@@ -0,0 +1,28 @@
/**
* @license
* Copyright 2024 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
import * as Blockly from 'blockly-test/core';
/**
* Test: should be able to import a generator instance, class, and
* Order enum.
*/
import {
javascriptGenerator,
JavascriptGenerator,
Order,
} from 'blockly-test/javascript';
/**
* Test: should be able to create a simple block generator function,
* correctly typed, and insert it into the .forBlock dictionary.
*/
javascriptGenerator.forBlock['the_answer'] = function (
_block: Blockly.Block,
_generator: JavascriptGenerator,
): [string, Order] {
return ['42', Order.ATOMIC];
};

View File

@@ -0,0 +1,24 @@
/**
* @license
* Copyright 2024 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
import * as Blockly from 'blockly-test/core';
/**
* Test: should be able to import a generator instance, class, and
* Order enum.
*/
import {luaGenerator, LuaGenerator, Order} from 'blockly-test/lua';
/**
* Test: should be able to create a simple block generator function,
* correctly typed, and insert it into the .forBlock dictionary.
*/
luaGenerator.forBlock['the_answer'] = function (
_block: Blockly.Block,
_generator: LuaGenerator,
): [string, Order] {
return ['42', Order.ATOMIC];
};

View File

@@ -0,0 +1,24 @@
/**
* @license
* Copyright 2024 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
import * as Blockly from 'blockly-test/core';
/**
* Test: should be able to import a generator instance, class, and
* Order enum.
*/
import {phpGenerator, PhpGenerator, Order} from 'blockly-test/php';
/**
* Test: should be able to create a simple block generator function,
* correctly typed, and insert it into the .forBlock dictionary.
*/
phpGenerator.forBlock['the_answer'] = function (
_block: Blockly.Block,
_generator: PhpGenerator,
): [string, Order] {
return ['42', Order.ATOMIC];
};

View File

@@ -0,0 +1,24 @@
/**
* @license
* Copyright 2024 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
import * as Blockly from 'blockly-test/core';
/**
* Test: should be able to import a generator instance, class, and
* Order enum.
*/
import {pythonGenerator, PythonGenerator, Order} from 'blockly-test/python';
/**
* Test: should be able to create a simple block generator function,
* correctly typed, and insert it into the .forBlock dictionary.
*/
pythonGenerator.forBlock['the_answer'] = function (
_block: Blockly.Block,
_generator: PythonGenerator,
): [string, Order] {
return ['42', Order.ATOMIC];
};

2
typings/dart.d.ts vendored
View File

@@ -4,4 +4,4 @@
* SPDX-License-Identifier: Apache-2.0
*/
export * from 'generators/dart';
export * from './generators/dart';

View File

@@ -4,4 +4,4 @@
* SPDX-License-Identifier: Apache-2.0
*/
export * from 'generators/javascript';
export * from './generators/javascript';

2
typings/lua.d.ts vendored
View File

@@ -4,4 +4,4 @@
* SPDX-License-Identifier: Apache-2.0
*/
export * from 'generators/lua';
export * from './generators/lua';

2
typings/php.d.ts vendored
View File

@@ -4,4 +4,4 @@
* SPDX-License-Identifier: Apache-2.0
*/
export * from 'generators/php';
export * from './generators/php';

2
typings/python.d.ts vendored
View File

@@ -4,4 +4,4 @@
* SPDX-License-Identifier: Apache-2.0
*/
export * from 'generators/python';
export * from './generators/python';