-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Closed
Labels
component: TypeScriptissue: bugDescribes why the code or behaviour is wrongDescribes why the code or behaviour is wrong
Description
I have a TS project that depends on blockly. When upgrading my blockly version to 9.0.0-beta.0, I have the following errors when doing tsc --watch in my project:
[11:27:56 AM] Starting compilation in watch mode...
node_modules/blockly/core/block.ts:1416:22 - error TS2339: Property 'substring' does not exist on type 'any[]'.
1416 text = (text.substring(0, opt_maxLength - 3) + '...') as
~~~~~~~~~
node_modules/blockly/core/block.ts:1420:5 - error TS2322: Type 'any[]' is not assignable to type 'string'.
1420 return text;
~~~~~~~~~~~~
node_modules/blockly/core/field_registry.ts:71:7 - error TS2352: Conversion of type 'Field' to type 'IRegistrableField' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.
Property 'fromJson' is missing in type 'Field' but required in type 'IRegistrableField'.
71 registry.getObject(registry.Type.FIELD, options['type']) as
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
72 IRegistrableField |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
73 null;
~~~~~~~~~~
node_modules/blockly/core/interfaces/i_registrable_field.ts:30:3
30 fromJson: fromJson;
~~~~~~~~
'fromJson' is declared here.
node_modules/blockly/core/generator.ts:162:17 - error TS2339: Property 'replace' does not exist on type 'any[]'.
162 code = code.replace(/\n\s+$/, '\n');
~~~~~~~
node_modules/blockly/core/generator.ts:163:17 - error TS2339: Property 'replace' does not exist on type 'any[]'.
163 code = code.replace(/[ \t]+\n/g, '\n');
~~~~~~~
node_modules/blockly/core/generator.ts:164:5 - error TS2322: Type 'any[]' is not assignable to type 'string'.
164 return code;
~~~~~~~~~~~~
node_modules/blockly/core/utils/toolbox.ts:428:3 - error TS2322: Type 'string | Element' is not assignable to type 'Element'.
Type 'string' is not assignable to type 'Element'.
428 return toolboxDef;
To Reproduce
Have a project that depends on blockly@9.0.0-beta.0 with the following tsconfig.json file. Note that the above errors cannot be bypassed even when setting skipLibCheck to true.
{
"compileOnSave": true,
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"sourceMap": false,
"removeComments": true,
"listEmittedFiles": false,
"newLine": "LF",
"downlevelIteration" : true,
"incremental": true,
"jsx": "react",
"resolveJsonModule": true,
"lib": [
"dom",
"es2021",
"WebWorker",
],
"skipLibCheck": true,
"baseUrl": ".",
"paths": {
"shared/*": ["src/shared/*"]
},
},
}
An easier way to reproduce the same errors is to mess with the tsconfig.json file of the blockly project directly: (Changes are marked with ****). Then run tsc --watch.
{
"include": [
"core/**/*", // N.B.: also pulls in closure/goog/goog.js if needed.
"closure/**/*", // Just for ouptut directory structure.
],
"exclude": [
"core/blockly.js"
],
"compilerOptions": {
"allowJs": false, // **** set this to false
"declaration": true,
"sourceMap": true,
"module": "ES2015",
"moduleResolution": "node",
"target": "ES2020",
"strict": false, // **** set this to false
// **** add the 'lib' and 'skipLibCheck' entries
"lib": [
"dom",
"es2021",
"WebWorker",
],
"skipLibCheck": true,
}
}
Desktop:
- OS: Ubuntu 22.04
- tsc: 4.4.3
Metadata
Metadata
Assignees
Labels
component: TypeScriptissue: bugDescribes why the code or behaviour is wrongDescribes why the code or behaviour is wrong