Property X never defined on Y
See original GitHub issueI’m running into this issue,
// index.js
import Type from './Type'
const t = new Type()
t.fromXML('Hello world', { name: 'test', optional: false })
console.log(t.type)
// Type.js
/**
* A representation of a type.
* @extends {typal.Type}
*/
export default class Type {
fromXML(content, props) {
this.type = props.name
this.desc = content
}
}
// depack/prop/externs.js
/** @const */
var typal = {}
/**
* @typedef {{ type: string, desc: string }}
*/
typal.Type
I’m pretty sure if something extends an extern, it should preserve its own methods as well.
-jar compiler.jar --compilation_level ADVANCED \
--language_out ECMASCRIPT_2017 \
--formatting PRETTY_PRINT --externs depack/prop/externs.js \
--module_resolution NODE \
--js depack/prop/index.js depack/prop/Type.js
Compiles fine though
class a {
}
;const b = new a;
b.type = "test";
b.desc = "Hello world";
console.log(b.type);
Don’t want the warning though.
depack/prop/index.js:4: WARNING - Property fromXML never defined on Type
t.fromXML('Hello world', { name: 'test', optional: false })
^^^^^^^
0 error(s), 1 warning(s), 87.0% typed
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
"Property never defined on any type in the program" error ...
A workaround is to avoid typedefs in externs like this; e.g. here I'm declaring a non-existent constructor purely for type hinting: /** @ ......
Read more >error TS2339: Property 'x' does not exist on type 'Y'
I'm no expert in Typescript, but I think the main problem is the way of accessing data. Seeing how you described your Images...
Read more >Property is missing in type 'X' but required in type 'Y' | bobbyhadz
The TypeScript error "Property is missing in type but required in type" occurs when we do not set all of the properties an...
Read more >TypeError: can't define property "x": "obj" is not extensible
The JavaScript exception "can't define property "x": "obj" is not extensible" occurs when Object.preventExtensions() marked an object as no ...
Read more >Documentation - Everyday Types - TypeScript
To define an object type, we simply list its properties and their types. ... with a type with two properties - x and...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@zavr-1 I’m glad you’ve found a solution.
hi yeah i’ve figured it out I could do that thank you, did something like that (without externs, because the whole point of externs was to avoid an error saying that I cannot assign to uninitialised properties on a structure, so I just initialise them all in the constructor to null. , please feel free to close this.